Add __orig_bases__ to TypedDict classes (#10221)

This commit is contained in:
Alex Waygood
2023-05-25 16:34:31 +01:00
committed by GitHub
parent 7994f165da
commit 4190dbca10
2 changed files with 5 additions and 0 deletions

View File

@@ -870,6 +870,10 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
if sys.version_info >= (3, 9):
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
# __orig_bases__ sometimes exists on <3.12, but not consistently,
# so we only add it to the stub on 3.12+
if sys.version_info >= (3, 12):
__orig_bases__: ClassVar[tuple[Any, ...]]
def copy(self) -> typing_extensions.Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through.

View File

@@ -148,6 +148,7 @@ class _TypedDict(Mapping[str, object], metaclass=abc.ABCMeta):
__required_keys__: ClassVar[frozenset[str]]
__optional_keys__: ClassVar[frozenset[str]]
__total__: ClassVar[bool]
__orig_bases__: ClassVar[tuple[Any, ...]]
def copy(self) -> Self: ...
# Using Never so that only calls using mypy plugin hook that specialize the signature
# can go through.