diff --git a/stdlib/@python2/typing.pyi b/stdlib/@python2/typing.pyi index 95df82a2a..f0e3dc403 100644 --- a/stdlib/@python2/typing.pyi +++ b/stdlib/@python2/typing.pyi @@ -23,12 +23,19 @@ _promote = object() class _SpecialForm(object): def __getitem__(self, typeargs: Any) -> object: ... -Union: _SpecialForm = ... -Optional: _SpecialForm -Tuple: _SpecialForm +# Unlike the vast majority module-level objects in stub files, +# these `_SpecialForm` objects in typing need the default value `= ...`, +# due to the fact that they are used elswhere in the same file. +# 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. Generic: _SpecialForm = ... Protocol: _SpecialForm = ... Callable: _SpecialForm = ... +Union: _SpecialForm = ... + +Optional: _SpecialForm +Tuple: _SpecialForm Type: _SpecialForm ClassVar: _SpecialForm Final: _SpecialForm diff --git a/stdlib/@python2/typing_extensions.pyi b/stdlib/@python2/typing_extensions.pyi index 9f048af40..42d513501 100644 --- a/stdlib/@python2/typing_extensions.pyi +++ b/stdlib/@python2/typing_extensions.pyi @@ -14,26 +14,24 @@ from typing import ( # noqa Y022 Mapping, NewType as NewType, NoReturn as NoReturn, + Protocol as Protocol, Text as Text, Type as Type, TypeVar, ValuesView, _Alias, overload as overload, + runtime_checkable as runtime_checkable, ) _T = TypeVar("_T") _F = TypeVar("_F", bound=Callable[..., Any]) -_TC = TypeVar("_TC", bound=type[object]) class _SpecialForm: def __getitem__(self, typeargs: Any) -> Any: ... -def runtime_checkable(cls: _TC) -> _TC: ... - # This alias for above is kept here for backwards compatibility. runtime = runtime_checkable -Protocol: _SpecialForm = ... Final: _SpecialForm def final(f: _F) -> _F: ... diff --git a/stdlib/typing.pyi b/stdlib/typing.pyi index df610291c..87abf763f 100644 --- a/stdlib/typing.pyi +++ b/stdlib/typing.pyi @@ -41,16 +41,23 @@ _T = TypeVar("_T") def overload(func: _F) -> _F: ... +# Unlike the vast majority module-level objects in stub files, +# these `_SpecialForm` objects in typing need the default value `= ...`, +# due to the fact that they are used elswhere in the same file. +# 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 = ... -Optional: _SpecialForm -Tuple: _SpecialForm Generic: _SpecialForm = ... # Protocol is only present in 3.8 and later, but mypy needs it unconditionally Protocol: _SpecialForm = ... Callable: _SpecialForm = ... Type: _SpecialForm = ... -ClassVar: _SpecialForm NoReturn: _SpecialForm = ... + +Optional: _SpecialForm +Tuple: _SpecialForm +ClassVar: _SpecialForm if sys.version_info >= (3, 8): Final: _SpecialForm def final(f: _T) -> _T: ... diff --git a/stdlib/typing_extensions.pyi b/stdlib/typing_extensions.pyi index dc2062b8c..e4d4f055e 100644 --- a/stdlib/typing_extensions.pyi +++ b/stdlib/typing_extensions.pyi @@ -22,26 +22,24 @@ from typing import ( # noqa Y022 Mapping, NewType as NewType, NoReturn as NoReturn, + Protocol as Protocol, Text as Text, Type as Type, TypeVar, ValuesView, _Alias, overload as overload, + runtime_checkable as runtime_checkable, ) _T = TypeVar("_T") _F = TypeVar("_F", bound=Callable[..., Any]) -_TC = TypeVar("_TC", bound=type[object]) class _SpecialForm: def __getitem__(self, typeargs: Any) -> Any: ... -def runtime_checkable(cls: _TC) -> _TC: ... - # This alias for above is kept here for backwards compatibility. runtime = runtime_checkable -Protocol: _SpecialForm = ... Final: _SpecialForm Self: _SpecialForm Required: _SpecialForm