Replies: 4 comments
-
Thanks, I think this kind of violation will be caught easily by a type checker where if |
Beta Was this translation helpful? Give feedback.
-
Thanks for the input. |
Beta Was this translation helpful? Give feedback.
-
There is an existing rule for this in flake8-pyi, although it is disabled by default, since it has a relatively high rate of false positives, and has not been ported to ruff: https://github.com/PyCQA/flake8-pyi/blob/main/ERRORCODES.md#Y090 Generally a lot of the flake8-pyi rules have not been ported, since they're so opinionated and specific to typeshed's guidelines. |
Beta Was this translation helpful? Give feedback.
-
That's exactly the warning I'm proposing. I don't know about the rest of the rules, but this rule in particular makes a lot of sense to me and I would not expect a high rate of false positives. |
Beta Was this translation helpful? Give feedback.
-
Maybe it started as a list of integers and at some point you realized that a tuple makes more sense, so what you have now is this:
nums: tuple[int] # maybe was a list[int] once
You just forgot to add the ellipsis. A warning would have saved me a few head-scratching minutes.
Cheers,
Tom
Beta Was this translation helpful? Give feedback.
All reactions