-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
More rules out of stub author's control #14535
Comments
Thanks! Your analysis all seems correct to me. I'd happily accept PRs disapplying these rules to stub files. For E741 we were quite cautious, and made the change preview-only for several minor releases before stabilising the change. I don't think we need to be as cautious this time around. Our versioning policy states that it's fine to apply changes in patch releases if they reduce scope (and these would be reductions in scope); we only need to wait for a minor release if a change increases the scope of a rule. |
The linked PR is for all but the last two bullets since those were suggested with less oomph 😄 |
This PR causes the following rules to ignore stub files, on the grounds that it is not under the author's control to appease these lints: - `PLR0904` https://docs.astral.sh/ruff/rules/too-many-public-methods/ - `PLR0913` https://docs.astral.sh/ruff/rules/too-many-arguments/ - `PLR0917` https://docs.astral.sh/ruff/rules/too-many-positional-arguments/ - `PLW3201` https://docs.astral.sh/ruff/rules/bad-dunder-method-name/ - `SLOT` https://docs.astral.sh/ruff/rules/#flake8-slots-slot - `FBT` https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt (except for FBT003 since that involves a function call.) Progress towards #14535
@dylwil3 Is this issue resolved or is there something left to be done? |
I leave that to @Samuel-Therrien-Beslogic to decide - as I said, I did not do anything regarding the last two bullet points. So it depends on whether there is interest in continuing to discuss those items. |
Thanks @dylwil3 ! For
But also
(that last sentence is why I've been ignoring it, since more often then not there's no alternatives other than re-writing Aliases, TypeVars and Protocols) So I'm not 100% convinced either way whether this should be disabled for everyone.
The following I'm pretty sure should be disabled in stubs:
As for the rest:
|
Just wanted to chime in and say that most if not all of the pep8-naming (N) rules should probably not be applied to stub files either. |
I did an experiment where I enabled nearly all rules in typeshed, and here's what I found typeshed would disable in PYI files (that isn't just an opinionated matter): https://github.com/Avasam/typeshed/pull/39/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
As for opinionated rules: |
Ruff 0.8.0 ignores
ambiguous-variable-name (E741)
automatically in pyi files. This prompted me to look at other rules I disable specifically for.pyi
files and found the following which I think should apply in all cases:PLR0904
https://docs.astral.sh/ruff/rules/too-many-public-methods/PLR0913
https://docs.astral.sh/ruff/rules/too-many-arguments/PLR0917
https://docs.astral.sh/ruff/rules/too-many-positional-arguments/PLW3201
https://docs.astral.sh/ruff/rules/bad-dunder-method-name/SLOT
https://docs.astral.sh/ruff/rules/#flake8-slots-slotFBT
https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbtA
https://docs.astral.sh/ruff/rules/#flake8-builtins-aPLC2701
https://docs.astral.sh/ruff/rules/import-private-name/I haven't gone back and validated if these still trigger in stub files since I added them to our shared config, sorry if I tagged a rule that's already ignored.
The text was updated successfully, but these errors were encountered: