I was wondering why Python's typing module does not support isinstance(<obj>, Any)
and raises a TypeError
. I would expect it to always return True
. Is there a specific reason why it does not always return True
?
- The TypeError is raised here.
- Example of the TypeError:
>>> from typing import Any
>>> isinstance(1, Any)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/peter/miniconda3/envs/prefect_utils/lib/python3.9/typing.py", line 338, in __instancecheck__
raise TypeError(f"{self} cannot be used with isinstance()")
TypeError: typing.Any cannot be used with isinstance()