Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,14 @@ _promote = object()
# N.B. Keep this definition in sync with typing_extensions._SpecialForm
@_final
class _SpecialForm:
def __getitem__(self, parameters: Any) -> object: ...
if sys.version_info >= (3, 10):
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...


class _SubscriptableSpecialForm(_SpecialForm): # type: ignore
def __getitem__(self, parameters: Any) -> object: ...

_F = TypeVar("_F", bound=Callable[..., Any])
_P = _ParamSpec("_P")
_T = TypeVar("_T")
Expand All @@ -503,26 +506,26 @@ def overload(func: _F) -> _F: ...
# Otherwise, flake8 erroneously flags them as undefined.
# `_SpecialForm` objects in typing.py that are not used elswhere in the same file
# do not need the default value assignment.
Union: _SpecialForm = ...
Generic: _SpecialForm = ...
Union: _SubscriptableSpecialForm = ...
Generic: _SubscriptableSpecialForm = ...
# Protocol is only present in 3.8 and later, but mypy needs it unconditionally
Protocol: _SpecialForm = ...
Callable: _SpecialForm = ...
Type: _SpecialForm = ...
Protocol: _SubscriptableSpecialForm = ...
Callable: _SubscriptableSpecialForm = ...
Type: _SubscriptableSpecialForm = ...
NoReturn: _SpecialForm = ...

Optional: _SpecialForm
Tuple: _SpecialForm
ClassVar: _SpecialForm
Optional: _SubscriptableSpecialForm
Tuple: _SubscriptableSpecialForm
ClassVar: _SubscriptableSpecialForm
if sys.version_info >= (3, 8):
Final: _SpecialForm
Final: _SubscriptableSpecialForm
def final(f: _T) -> _T: ...
Literal: _SpecialForm
Literal: _SubscriptableSpecialForm
# TypedDict is a (non-subscriptable) special form.
TypedDict: object

if sys.version_info >= (3, 11):
Self: _SpecialForm
Self: _SubscriptableSpecialForm
Never: _SpecialForm = ...

if sys.version_info < (3, 7):
Expand Down