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 stumbled upon this couple of times so I guess it's fairly reasonable to report this. Currently mypy understand isinstance() and will properly resolve types when isinstance() is used inside if statement:
example.py:11: note: Revealed type is 'Union[builtins.int, builtins.str]'
This is somewhat annoying if you have a complex isinstance() call that you don't want to copy in your code over and over again but simply hide it under a descriptive function name.
I stumbled upon this couple of times so I guess it's fairly reasonable to report this. Currently
mypy
understandisinstance()
and will properly resolve types whenisinstance()
is used insideif
statement:However, if you move
isinstance()
call to function that basically wraps it, mypy fails to narrow a type of variable.This is somewhat annoying if you have a complex
isinstance()
call that you don't want to copy in your code over and over again but simply hide it under a descriptive function name.This might be somehow related to #4573.
Versions
The text was updated successfully, but these errors were encountered: