-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Split PIE790
into separate rules for unnecessary pass
vs ...
; I want to keep ...
in example code
#10538
Comments
Given all the problems we've had with ellipses in type checking contexts it might indeed be sensible to just split these into separate rules 🤔 |
I'm fine with it. We could implement the related Pylint rule (https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/unnecessary-ellipsis.html) and remove ellipses from this rule (although we just added them here, it was originally in preview). |
It may also be helpful to think about how we would categorize the two rules in the future. It would be a strong reason to split them if we would categorize them differently. I'm undecided on the categories but my initial thinking is:
CC: @AlexWaygood |
I think it's reasonable to want to distinguish between I know pyright treats So I see the motivation for removing |
@AlexWaygood so what I understand from your description is that you would configure both rules with the same severity? Would the detection of |
Yeah, I would probably have them both in the same category and the same severity, and would probably have them both enabled by default. But as I say, no strong opinion here. |
Here's the relevant commentary from the Pyright author just for reference #8756 I sort of strongly prefer separate rules over configuration options. Are all "useless statements" going to go into "complexity"? |
I haven't yet decided whether "complexity" will be its own category in my proposal, or just a subcategory (and whatever I propose, we'll obviously discuss it internally before going ahead with anything 😄). But to me, it makes sense for all "useless statement" rules to be part of the same category, yeah |
It feels like a bit of a weird home. I'd never turn on the complexity rules personally, but I would absolutely want useless statements to be detected. I'd say it's almost "suspicious" :) but of course a |
Yeah I think "style" might make more sense than "complexity" for "redundant statement" rules. (I only said above that I thought they should all be in the same category ;). But let's not get too into the weeds of rule recategorisation details here ;) |
The autofix to remove useless
pass
statements is great, but I currently disable the whole rule because it also catches...
. These constructs are equivalent at execution time, but ellipses do in fact convey something to the reader, and therefore I want to keep them for example code. Consider e.g.:In other cases, it's useful to show where not-currently-relevant code has been omitted. Using a comment is sometimes a reasonable substitute, but in already-commented code it's nice to have a distinguished marker which is not an explanatory comment.
I'm aware of a variety of other uses in type-checking etc. which might also motivate splitting out this rule, but haven't looked into them.
The text was updated successfully, but these errors were encountered: