Skip to content

False positive for undefined variable with assignment expression #3688

@hauntsaninja

Description

@hauntsaninja

Steps to reproduce

# ~/tmp λ cat test4.py
def i(am: str = (the := "walrus")) -> str:
    return "goo goo g'joob"
print(the)

Current behavior

~/tmp λ pylint -E test4.py
************* Module test4
test4.py:5:6: E0602: Undefined variable 'the' (undefined-variable)

Expected behavior

pylint recognises that the is defined. (Or alternatively, pylint yells at me for doing this weird thing in the first place ;-) )

pylint --version output

~/tmp λ pylint --version
pylint 2.5.3
astroid 2.4.2
Python 3.8.3 (default, May 27 2020, 20:54:22) 
[Clang 11.0.3 (clang-1103.0.32.59)]

Pretty minor, especially given that assignment expressions aren't a priority for pylint (#3275 (comment)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Assignment expressionRelated to the walrus operator / assignment expressionFalse Positive 🦟A message is emitted but nothing is wrong with the codepython 3.8

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions