You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code results in UnboundLocalError: local variable 'result' referenced before assignment if run, but mypy does not report an issue.
deffoo(input: bool):
ifinput:
result="value"print('result set')
else:
print('result is not assigned')
returnresulta=foo(False)
Expected Behavior
I would expect mypy to complain about result being referenced before assignment.
Actual Behavior
Success: no issues found in 1 source file
Your Environment
Mypy version used: 0.980+dev.61a9b92297e1363b5bd99855df51e9a84be8da69 (current master)
Mypy command-line flags: (none)
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3.10.5 and 3.9.7 (both with pyenv)
Operating system and version: Ubuntu 20.04.4 LTS
Notes
This is my firt bug report to mypy, so I'm sorry if this issue is already reported (I was not able to find it), or if this is out of scope for mypy. I do also realize that this is halting-problem-esque, but I believe this category of problem should be possible to resolve with static analysis.
The text was updated successfully, but these errors were encountered:
Bug Report
Not catching reference before assignment.
To Reproduce
The following code results in
UnboundLocalError: local variable 'result' referenced before assignment
if run, but mypy does not report an issue.Expected Behavior
I would expect mypy to complain about
result
being referenced before assignment.Actual Behavior
Your Environment
mypy.ini
(and other config files): noneNotes
This is my firt bug report to mypy, so I'm sorry if this issue is already reported (I was not able to find it), or if this is out of scope for mypy. I do also realize that this is halting-problem-esque, but I believe this category of problem should be possible to resolve with static analysis.
The text was updated successfully, but these errors were encountered: