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
I was trying to debug why I was getting no-redef errors when I had --allow-redefinition. I had seen #6963 so, I figured that because both the definition and use of the variable were in a loop it was not triggering that condition (variable use). This did not turn out to be the case, and I was looking through similar issues I noticed #7984 and the example given did exhibit what I was trying to do and what I expected to work. I was able to confirm that it was working on the version of mypy I was using and I set to reduce my test case to something that was easy to reproduce. I made sure everything was typed by stubbing in concrete definitions and started to pull pieces of my test case apart.
Quickly and surprisingly I found out that a closure function I had defined was breaking the redefinition, but the enclosed function was unrelated to the variable. Without further ado:
note: In function "f":
7: note: Revealed type is 'builtins.int'
13: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]
x = 'x'
^
t2.py:14: note: Revealed type is 'builtins.int'
Bug Report
I was trying to debug why I was getting
no-redef
errors when I had--allow-redefinition
. I had seen #6963 so, I figured that because both the definition and use of the variable were in a loop it was not triggering that condition (variable use). This did not turn out to be the case, and I was looking through similar issues I noticed #7984 and the example given did exhibit what I was trying to do and what I expected to work. I was able to confirm that it was working on the version of mypy I was using and I set to reduce my test case to something that was easy to reproduce. I made sure everything was typed by stubbing in concrete definitions and started to pull pieces of my test case apart.Quickly and surprisingly I found out that a closure function I had defined was breaking the redefinition, but the enclosed function was unrelated to the variable. Without further ado:
To Reproduce
Expected Behavior
reveal_type 1:
int
reveal_type: 2: 'str'
Actual Behavior
Your Environment
--warn-unused-configs --allow-redefinition
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: