-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable some Ruff TC rules (flake8-type-checking) #13333
Conversation
I'm a little concerned about enabling this whole category because some of the rules in this category are quite opinionated stylistic rules. That might not be an issue for us right now, but it could become an issue in the future if Ruff stabilises an opinionated rule and we don't agree with it. For this category, I think I'd prefer to just enable the specific rules that we think would be useful for this repository |
I'm guessing that any rules that moves stuff into a type-checking block, or adds quotes around an annotation are things we're not concerned with, and would rather keep the simplicity of not quoting/extra conditional block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, these three seem reasonable to me!
FWIW I try to keep the opinionated stuff from TC005, TC008 and TC010 are as of 0.8.5 the only rules that work in stub files. So you could actually safely enable TC, but it also doesn't hurt to be more selective to signal intent. I just thought I'd mention it, since you currently have TC004 selected, which doesn't actually work in stubs (although it probably could, but the logic would have to be different. If you want it to work feel free to open an issue on ruff's repository and @ me, should be easy to implement). |
Thanks!
We also lint our tests and scripts, which have been growing in size and complexity. The Ruff rules we enable are not exclusive to stubs. But we're less strict with the rules we enforce for those. |
Ref #13295
https://docs.astral.sh/ruff/rules/#flake8-type-checking-tc
All rules are autofixable
I doubt we'd want to add a bunch if
if TYPE_CHECKING
blocks in typeshed's scripts (unless we have an explicit reason to do so), so I pre-emptively disabledTC001
,TC002
andTC003
. The rest seem like useful checks that are not necessarily covered by type-checkers.