-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Regression used-before-assignment
with type annotation
#5342
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
Labels
Comments
I'll have a look! |
For future reference. This does create a false positive: class MyClass:
def self_referential_optional_within_method(self) -> None:
variable: Optional[MyClass] = self
print(variable)
def correct_inner_typing_method(self) -> bool:
def inner_method(self, other: MyClass) -> bool:
return self == other
return inner_method(self, MyClass()) But this doesn't: class MyClass:
def correct_inner_typing_method(self) -> bool:
def inner_method(self, other: MyClass) -> bool:
return self == other
return inner_method(self, MyClass())
def self_referential_optional_within_method(self) -> None:
variable: Optional[MyClass] = self
print(variable) This is (somewhat) blocked by #5241 as I would like to merge the refactor before working on this to avoid future merge conflicts. |
17 tasks
The-Compiler
added a commit
to qutebrowser/qutebrowser
that referenced
this issue
Dec 2, 2021
4 tasks
FWIW I can confirm this seems fully fixed in 2.12.2 - thanks everyone! |
mkonig
pushed a commit
to mkonig/qutebrowser
that referenced
this issue
Dec 7, 2021
4 tasks
twigleingrid
pushed a commit
to twigleingrid/qutebrowser
that referenced
this issue
May 13, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug description
Noticed this in
astroid
first -> astroid/nodes/node_ng.py. The example above is valid as the function body isn't evaluated until called at witch time the class is already defined. This is a regression inmain
compared tov2.11.1
./CC: @DanielNoord Haven't looked at it yet, but I would guess this might be related to the work you've been doing in this area.
Configuration
No response
Command used
Pylint output
E0601: Using variable 'A' before assignment (used-before-assignment)
Expected behavior
No error
Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: