Skip to content
Open
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ typing.type_check_only # typing decorator that is not available at runtime
# Details of runtime definition don't need to be in stubs
typing._Final
typing._Final.__init_subclass__
typing\.Protocol
typing(_extensions)?\._TypedDict
typing(_extensions)?\.Any.*
typing(_extensions)?\.TypedDict
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ multiprocessing.managers._BaseDictProxy.values
# To match `dict`, we lie about the runtime, but use overloads to match the correct behavior
types.MappingProxyType.get

typing_extensions.Protocol # Super-special typing primitive


# =============================================================
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py315.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ multiprocessing.managers._BaseDictProxy.values
# To match `dict`, we lie about the runtime, but use overloads to match the correct behavior.
types.MappingProxyType.get

typing_extensions.Protocol # Super-special typing primitive

copy.replace # Cannot have keyword-only ParamSpec

Expand Down
6 changes: 5 additions & 1 deletion stdlib/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ class _SpecialForm(_Final):
def __ror__(self, other: Any) -> _SpecialForm: ...

Union: _SpecialForm
Protocol: _SpecialForm
Callable: _SpecialForm
Type: _SpecialForm
NoReturn: _SpecialForm
Expand Down Expand Up @@ -472,6 +471,11 @@ class _Generic:

Generic: type[_Generic]

@type_check_only
class _Protocol: ...

Protocol: type[_Protocol]

class _ProtocolMeta(ABCMeta):
if sys.version_info >= (3, 12):
def __init__(cls, *args: Any, **kwargs: Any) -> None: ...
Expand Down
5 changes: 4 additions & 1 deletion stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,15 @@ _T_contra = _TypeVar("_T_contra", contravariant=True)
if sys.version_info < (3, 15):
def no_type_check_decorator(decorator: _F) -> _F: ...

@type_check_only
class _Protocol: ...

# Do not import (and re-export) Protocol or runtime_checkable from
# typing module because type checkers need to be able to distinguish
# typing.Protocol and typing_extensions.Protocol so they can properly
# warn users about potential runtime exceptions when using typing.Protocol
# on older versions of Python.
Protocol: _SpecialForm
Protocol: type[_Protocol]

def runtime_checkable(cls: _TC) -> _TC: ...

Expand Down