from typing import Any
class X:
def __instancecheck__(cls, x: Any) -> bool:
return False
x: X = X()
var: Any = 123
if isinstance(var, x): # Argument 2 to "isinstance" has incompatible type "X"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"
reveal_type(var) # Any
else:
reveal_type(var) # Any
Expected Behavior
No errors. First reveal_type should reveal (I honestly don't know what should be here, maybe "x" or something like "InstanceOf[X]"?), second - Any
Actual Behavior
Argument 2 to "isinstance" has incompatible type "X"; expected "Union[huge union]" error. Both reveal_type's reveals Any
At runtime i get no error.
My Environment
mypy 0.961 (compiled: no)
- no command-line flags, no config file
CPython 3.10.4
- Windows 10
Expected Behavior
No errors. First
reveal_typeshould reveal(I honestly don't know what should be here, maybe "x" or something like "InstanceOf[X]"?), second -AnyActual Behavior
Argument 2 to "isinstance" has incompatible type "X"; expected "Union[huge union]"error. Bothreveal_type's revealsAnyAt runtime i get no error.
My Environment
mypy 0.961 (compiled: no)CPython 3.10.4