-
Notifications
You must be signed in to change notification settings - Fork 65
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
lint-fixme
comments not respected
#405
Comments
lint-fixme
comments ignored inside list comprehensionslint-fixme
comments not respected
I've found another one that's causing us problems: decorators. from dataclasses import dataclass
@dataclass()
class C:
pass
# lint-fixme: ExplicitFrozenDataclass
@dataclass()
class C:
pass
@dataclass() # lint-fixme: ExplicitFrozenDataclass
class C:
pass We'd expect the first function to be reported, and the other two to be silenced. t.py@4:0 ExplicitFrozenDataclass: When using dataclasses, explicitly specify a frozen keyword argument. Example: `@dataclass(frozen=True)` or `@dataclass(frozen=False)`. Docs: https://docs.python.org/3/library/dataclasses.html (has autofix)
t.py@10:0 ExplicitFrozenDataclass: When using dataclasses, explicitly specify a frozen keyword argument. Example: `@dataclass(frozen=True)` or `@dataclass(frozen=False)`. Docs: https://docs.python.org/3/library/dataclasses.html (has autofix)
🛠️ 1 file checked, 1 file with errors, 2 auto-fixes available 🛠️ But we see the first two reported. The last one is correctly silenced. |
I have written some failing tests to demonstrate these problems in #413. I haven't worked out how to demonstrate the function def problem yet, so I'd appreciate any advice you can offer there. |
This is necessary as a workaround to a bug in fixit (Instagram/Fixit#405).
I have found another case. This looks superficially similar to the comprehensions case. In the following file ( def f(x):
return (
isinstance(x, int) or isinstance(x, float)
)
def f(x):
return (
isinstance(x, int) or isinstance(x, float) # lint-fixme: CollapseIsinstanceChecks
)
def f(x):
return (
# lint-fixme: CollapseIsinstanceChecks
isinstance(x, int) or isinstance(x, float)
) However, the violation is reported for all three: $ fixit lint t.py
t.py@3:8 CollapseIsinstanceChecks: Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. (has autofix)
t.py@9:8 CollapseIsinstanceChecks: Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. (has autofix)
t.py@16:8 CollapseIsinstanceChecks: Multiple isinstance calls with the same target but different types can be collapsed into a single call with a tuple of types. (has autofix)
🛠️ 1 file checked, 1 file with errors, 3 auto-fixes available 🛠️ |
lint-fixme
comments on nodes in some cases are not respected.comprehensions
In the following file (
t.py
), we would expect the violation to be reported for the first function, but not for either of the other two.However, the violation is reported for all three:
lambdas
In the following file (
t.py
), we would expect the violation to be reported for the first list, but not for either of the other two.However, the violation is reported for all three:
EDIT: the commit is respected if it is placed before the list:
This is not expected, though, and means that multiple lines will be ignored rather than just the desired one.
methods
In the following file (
t.py
), we would expect the violation to be reported for the first class, but not for either of the other two.However, the violation is correctly silenced for the last case, but shown for the middle case that should be silenced:
supporting information
I have also observed this behaviour on Python 3.10.11.
The text was updated successfully, but these errors were encountered: