Closed
Description
Description
is_typeddict
from the typing
module does not correctly identify TypedDict
from the typing_extensions
module:
from typing_extensions import is_typeddict as is_typeddict_te, TypedDict as TypedDict_te
from typing import is_typeddict, TypedDict
class Ext(TypedDict_te):
a: int
class Reg(TypedDict):
a: int
print("is_typeddict(Ext):", is_typeddict(Ext)) # False
print("is_typeddict(Reg):", is_typeddict(Reg)) # True
print("is_typeddict_te(Ext):", is_typeddict_te(Ext)) # True
print("is_typeddict_te(Reg):", is_typeddict_te(Reg)) # True
In the description of UP035:
Note that, in some cases, it may be preferable to continue importing members from
typing_extensions
even after they're added to the Python standard library, astyping_extensions
can backport bugfixes and optimizations from later Python versions. This rule thus avoids flagging imports fromtyping_extensions
in such cases.