Runtime TypeError caused by mixing typing
and typing_extensions
not caught
#4380
Labels
as designed
Not a bug, working as intended
The last line of the following code results in the runtime TypeError:
I just ran into this runtime error because I always default to using types from
typing
but sometimes use types fromtyping_extensions
to support older versions of Python. In particulartyping.TypedDict
is incompatible withtyping.Generic
in Python < 3.11, see python/cpython#27663 (comment), so I sometimes usedtyping_extensions.TypedDict
instead oftyping.TypedDict
.It would be nice if pyright could detect this type error, which can be quite sneaky.
I think there could even be an additional optional check that warns about this issue whenever a project uses both
typing.TypedDict
andtyping_extensions.TypedDict
in the same code base (because otherwise the public API might haveTypedDict
classes that are incompatible with each other).The text was updated successfully, but these errors were encountered: