-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Update typing_extensions to 4.13.0rc1 #13671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
cf0f99f
Update typing_extensions to 4.13.0rc1
srittau 125ed8a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1ee04d6
Reorder allowlist
srittau 2062247
Update typing_extensions version in requirements
srittau d278359
Move allowlist entries to 3.12/3.13(?)
srittau 845802f
Add missing annotations
srittau df8abca
Remove unnecessary allowlist entries
srittau 63bddaa
Ignore flake8 warnings
srittau 60c3bc5
Use `type[object]`
srittau a1715b1
Remove TypeAliasType.__call__
srittau 9b89e3c
TypeAliasType.__parameters__ can include special forms
srittau 1b4a83a
Update a comment
srittau 8fa5a1b
Split line
srittau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| import abc | ||
| import enum | ||
| import sys | ||
| import typing | ||
| from _collections_abc import dict_items, dict_keys, dict_values | ||
| from _typeshed import IdentityFunction | ||
| from _typeshed import IdentityFunction, Incomplete | ||
| from contextlib import AbstractAsyncContextManager as AsyncContextManager, AbstractContextManager as ContextManager | ||
| from types import ModuleType | ||
| from typing import ( # noqa: Y022,Y037,Y038,Y039 | ||
| IO as IO, | ||
| TYPE_CHECKING as TYPE_CHECKING, | ||
|
|
@@ -68,9 +70,10 @@ if sys.version_info >= (3, 10): | |
| if sys.version_info >= (3, 9): | ||
| from types import GenericAlias | ||
|
|
||
| # Please keep order the same as at runtime. | ||
| __all__ = [ | ||
| # Super-special typing primitives. | ||
| "Any", | ||
| "Buffer", | ||
| "ClassVar", | ||
| "Concatenate", | ||
| "Final", | ||
|
|
@@ -83,35 +86,51 @@ __all__ = [ | |
| "TypeVar", | ||
| "TypeVarTuple", | ||
| "Unpack", | ||
| # ABCs (from collections.abc). | ||
| "Awaitable", | ||
| "AsyncIterator", | ||
| "AsyncIterable", | ||
| "Coroutine", | ||
| "AsyncGenerator", | ||
| "AsyncContextManager", | ||
| "CapsuleType", | ||
| "Buffer", | ||
| "ChainMap", | ||
| # Concrete collection types. | ||
| "ContextManager", | ||
| "Counter", | ||
| "Deque", | ||
| "DefaultDict", | ||
| "NamedTuple", | ||
| "OrderedDict", | ||
| "TypedDict", | ||
| "SupportsIndex", | ||
| # Structural checks, a.k.a. protocols. | ||
| "SupportsAbs", | ||
| "SupportsRound", | ||
| "SupportsBytes", | ||
| "SupportsComplex", | ||
| "SupportsFloat", | ||
| "SupportsIndex", | ||
| "SupportsInt", | ||
| "SupportsRound", | ||
| # One-off things. | ||
| "Annotated", | ||
| "assert_never", | ||
| "assert_type", | ||
| "clear_overloads", | ||
| "dataclass_transform", | ||
| "deprecated", | ||
| "Doc", | ||
| "evaluate_forward_ref", | ||
| "get_overloads", | ||
| "final", | ||
| "Format", | ||
| "get_annotations", | ||
| "get_args", | ||
| "get_origin", | ||
| "get_original_bases", | ||
| "get_protocol_members", | ||
| "get_type_hints", | ||
| "IntVar", | ||
| "is_protocol", | ||
| "is_typeddict", | ||
| "Literal", | ||
| "NewType", | ||
|
|
@@ -124,26 +143,25 @@ __all__ = [ | |
| "Text", | ||
| "TypeAlias", | ||
| "TypeAliasType", | ||
| "TypeForm", | ||
| "TypeGuard", | ||
| "TypeIs", | ||
| "TYPE_CHECKING", | ||
| "Never", | ||
| "NoReturn", | ||
| "ReadOnly", | ||
| "Required", | ||
| "NotRequired", | ||
| "clear_overloads", | ||
| "get_args", | ||
| "get_origin", | ||
| "get_original_bases", | ||
| "get_overloads", | ||
| "get_type_hints", | ||
| "NoDefault", | ||
| "NoExtraItems", | ||
| # Pure aliases, have always been in typing | ||
| "AbstractSet", | ||
| "AnyStr", | ||
| "BinaryIO", | ||
| "Callable", | ||
| "Collection", | ||
| "Container", | ||
| "Dict", | ||
| "Doc", | ||
| "ForwardRef", | ||
| "FrozenSet", | ||
| "Generator", | ||
|
|
@@ -161,7 +179,6 @@ __all__ = [ | |
| "MutableMapping", | ||
| "MutableSequence", | ||
| "MutableSet", | ||
| "NoDefault", | ||
| "Optional", | ||
| "Pattern", | ||
| "Reversible", | ||
|
|
@@ -173,12 +190,10 @@ __all__ = [ | |
| "Union", | ||
| "ValuesView", | ||
| "cast", | ||
| "get_protocol_members", | ||
| "is_protocol", | ||
| "no_type_check", | ||
| "no_type_check_decorator", | ||
| "ReadOnly", | ||
| "TypeIs", | ||
| # Added dynamically | ||
| "CapsuleType", | ||
| ] | ||
|
|
||
| _T = typing.TypeVar("_T") | ||
|
|
@@ -382,33 +397,11 @@ if sys.version_info >= (3, 12): | |
| SupportsIndex as SupportsIndex, | ||
| SupportsInt as SupportsInt, | ||
| SupportsRound as SupportsRound, | ||
| TypeAliasType as TypeAliasType, | ||
| override as override, | ||
| ) | ||
| else: | ||
| def override(arg: _F, /) -> _F: ... | ||
| def get_original_bases(cls: type, /) -> tuple[Any, ...]: ... | ||
| @final | ||
| class TypeAliasType: | ||
| def __init__( | ||
| self, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = () | ||
| ) -> None: ... | ||
| @property | ||
| def __value__(self) -> Any: ... | ||
| @property | ||
| def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ... | ||
| @property | ||
| def __parameters__(self) -> tuple[Any, ...]: ... | ||
| @property | ||
| def __name__(self) -> str: ... | ||
| # It's writable on types, but not on instances of TypeAliasType. | ||
| @property | ||
| def __module__(self) -> str | None: ... # type: ignore[override] | ||
| # Returns typing._GenericAlias, which isn't stubbed. | ||
| def __getitem__(self, parameters: Any) -> Any: ... | ||
| if sys.version_info >= (3, 10): | ||
| def __or__(self, right: Any) -> _SpecialForm: ... | ||
| def __ror__(self, left: Any) -> _SpecialForm: ... | ||
|
|
||
| # mypy and pyright object to this being both ABC and Protocol. | ||
| # At runtime it inherits from ABC and is not a Protocol, but it is on the | ||
|
|
@@ -569,8 +562,70 @@ else: | |
| ReadOnly: _SpecialForm | ||
| TypeIs: _SpecialForm | ||
|
|
||
| # TypeAliasType was added in Python 3.12, but had significant changes in 3.14. | ||
| if sys.version_info >= (3, 14): | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made an exception for our "next Python version" rule, as technically typing_extensions is not part of the stdlib. |
||
| from typing import TypeAliasType as TypeAliasType | ||
| else: | ||
| @final | ||
| class TypeAliasType: | ||
| def __init__( | ||
| self, name: str, value: Any, *, type_params: tuple[TypeVar | ParamSpec | TypeVarTuple, ...] = () | ||
| ) -> None: ... # value is a type expression | ||
| @property | ||
| def __value__(self) -> Any: ... # a type expression | ||
| @property | ||
| def __type_params__(self) -> tuple[TypeVar | ParamSpec | TypeVarTuple, ...]: ... | ||
| @property | ||
| def __parameters__(self) -> tuple[TypeVar | ParamSpec, ...]: ... | ||
|
AlexWaygood marked this conversation as resolved.
Outdated
|
||
| @property | ||
| def __name__(self) -> str: ... | ||
| # It's writable on types, but not on instances of TypeAliasType. | ||
| @property | ||
| def __module__(self) -> str | None: ... # type: ignore[override] | ||
| # Returns typing._GenericAlias, which isn't stubbed. | ||
| def __getitem__(self, parameters: Incomplete | tuple[Incomplete, ...]) -> Any: ... | ||
| def __init_subclass__(cls, *args, **kwargs) -> NoReturn: ... | ||
| def __call__(self) -> NoReturn: ... | ||
|
AlexWaygood marked this conversation as resolved.
Outdated
|
||
| if sys.version_info >= (3, 10): | ||
| def __or__(self, right: Any) -> _SpecialForm: ... | ||
| def __ror__(self, left: Any) -> _SpecialForm: ... | ||
|
|
||
| # PEP 727 | ||
| class Doc: | ||
| documentation: str | ||
| def __init__(self, documentation: str, /) -> None: ... | ||
| def __hash__(self) -> int: ... | ||
| def __eq__(self, other: object) -> bool: ... | ||
|
|
||
| # PEP 728 | ||
| class _NoExtraItemsType: ... | ||
|
|
||
| NoExtraItems: _NoExtraItemsType | ||
|
|
||
| # PEP 747 | ||
| TypeForm: _SpecialForm | ||
|
|
||
| class Format(enum.IntEnum): | ||
| VALUE = 1 | ||
| FORWARDREF = 2 | ||
| STRING = 3 | ||
|
|
||
| # PEP 649/749 | ||
| def get_annotations( | ||
| obj: Callable[..., object] | type[Any] | ModuleType, # any callable, class, or module | ||
| *, | ||
| globals: Mapping[str, Any] | None = None, # value types depend on the key | ||
| locals: Mapping[str, Any] | None = None, # value types depend on the key | ||
| eval_str: bool = False, | ||
| format: Format = Format.VALUE, | ||
| ) -> dict[str, Any]: ... # values are type expressions | ||
| def evaluate_forward_ref( | ||
| forward_ref: ForwardRef, | ||
| *, | ||
| owner: Callable[..., object] | type[Any] | ModuleType | None = None, # any callable, class, or module | ||
|
AlexWaygood marked this conversation as resolved.
Outdated
|
||
| globals: Mapping[str, Any] | None = None, # value types depend on the key | ||
| locals: Mapping[str, Any] | None = None, # value types depend on the key | ||
| type_params: Iterable[TypeVar | ParamSpec | TypeVarTuple] | None = None, | ||
| format: Format = Format.VALUE, | ||
| _recursive_guard: Container[str] = ..., | ||
| ) -> Any: ... # str if format is Format.STRING, otherwise a type expression | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.