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 false-positive used-before-assignment with := in Return node #4831

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ Release date: TBA

Closes #3839

* Fix false-positive ``used-before-assignment`` with an assignment expression in a ``Return`` node

Closes #4828


What's New in Pylint 2.9.6?
===========================
Expand Down
1 change: 1 addition & 0 deletions pylint/checkers/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,7 @@ def _is_variable_violation(
astroid.AnnAssign,
astroid.AugAssign,
astroid.Expr,
astroid.Return,
),
)
and isinstance(defstmt.value, astroid.IfExp)
Expand Down
5 changes: 5 additions & 0 deletions tests/functional/a/assign/assignment_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ def func():
def func2():
return f'The number {(count := 4)} ' \
f'is equal to {count}'


# https://github.com/PyCQA/pylint/issues/4828
def func3():
return bar if (bar := "") else ""