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
After the line val, foo = None, val, I would expect that
val has type None (ok)
foo has type Type[Any]
the call to eggs() passes
Actual Behavior
$ mypy test.py
test.py:9: note: Revealed type is 'Union[Type[Any], None]'
test.py:11: note: Revealed type is 'Type[Any]'
test.py:13: note: Revealed type is 'None'
test.py:14: note: Revealed type is 'None'
test.py:15: error: Argument 1 to "eggs" has incompatible type "None"; expected "Type[Any]"
Found 1 error in 1 file (checked 1 source file)
$ mypy test.py
test.py:9: note: Revealed type is 'Union[Type[Any], None]'
test.py:11: note: Revealed type is 'Type[Any]'
test.py:14: note: Revealed type is 'None'
test.py:15: note: Revealed type is 'Type[Any]'
Activity
[-]Wrong type hint after unpacking[/-][+]Wrong type hint after unpacking/swapping[/+]NiklasRosenstein commentedon Nov 18, 2020
Splitting the swap/unpacking into two lines works:
JelleZijlstra commentedon Nov 18, 2020
Sounds like we update the inferred local type of
valtoo soon. Hopefully this shouldn't be hard to fix.NiklasRosenstein commentedon Jun 4, 2021
I just hit this again in a different scenario.