Skip to content
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

Fix used-before-assignment for conditional self-referential typing #5532

Merged
merged 1 commit into from Dec 18, 2021

Conversation

DanielNoord
Copy link
Collaborator

  • Add yourself to CONTRIBUTORS if you are a new contributor.
  • Add a ChangeLog entry describing what your PR does.
  • If it's a new feature, or an important bug fix, add a What's New entry in
    doc/whatsnew/<current release.rst>.
  • Write a good description on what the PR does.

Type of Changes

Type
🐛 Bug fix

Description

Closes #5499.

I should have thought of this fix in #5342. This is much better..

@DanielNoord DanielNoord added False Positive 🦟 A message is emitted but nothing is wrong with the code C: used-before-assignment Issues related to 'used-before-assignment' check labels Dec 15, 2021
@DanielNoord DanielNoord added this to the 2.13.0 milestone Dec 15, 2021
@@ -1805,7 +1805,7 @@ def _is_first_level_self_reference(
"""
if (
node.frame().parent == defstmt
and node.statement(future=True) not in node.frame().body
and node.statement(future=True) == node.frame()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this work, could you explain ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically for arguments in function definitions their statement is also their frame (the function definition). For nodes within the body or even within sub-bodies (conditionals) the statement will be different from the frame (the latter still being the function definition).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thank you.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1584679706

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.65%

Totals Coverage Status
Change from base Build 1583088214: 0.0%
Covered Lines: 14232
Relevant Lines: 15197

💛 - Coveralls

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Pierre-Sassoulas Pierre-Sassoulas merged commit bb9cb4b into pylint-dev:main Dec 18, 2021
@DanielNoord DanielNoord deleted the used-before branch December 18, 2021 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: used-before-assignment Issues related to 'used-before-assignment' check False Positive 🦟 A message is emitted but nothing is wrong with the code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression used-before-assignment with type annotation in conditional
3 participants