Skip to content
2 changes: 1 addition & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ stubdefaulter==0.1.0; python_version < "3.15"
termcolor>=2.3
tomli==2.4.1; python_version < "3.11"
tomlkit==0.14.0
typing_extensions>=4.15.0rc1
typing_extensions>=4.16.0rc1
uv==0.11.15

# Utilities for typeshed infrastructure scripts.
Expand Down
13 changes: 7 additions & 6 deletions stdlib/@tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ typing_extensions.NewType.__mro_entries__
importlib.metadata._meta.SimplePath.__truediv__ # Runtime definition of protocol is incorrect


# ===================================
# Pre-existing errors from Python 3.9
# ===================================


# =======
# <= 3.10
# =======
Expand All @@ -56,9 +51,10 @@ tkinter.Tk.split # Exists at runtime, but missing from stubs
typing._SpecialForm.__mro_entries__ # Exists at runtime, but missing from stubs

typing_extensions.LiteralString

# Will always raise. Not included to avoid type checkers inferring that
# Sentinel instances are callable.
typing_extensions.Sentinel.__call__
typing_extensions.sentinel.__call__


# =======
Expand Down Expand Up @@ -141,6 +137,11 @@ tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion

# The runtime does some hacks to deprecate passing various parameters
# positionally or by keyword. We just present a signature in the stub
# that describes the way users are supposed to call the constructor.
typing_extensions.sentinel.__init__


# =============================================================
# Allowlist entries that cannot or should not be fixed; <3.15
Expand Down
5 changes: 5 additions & 0 deletions stdlib/@tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion

# The runtime does some hacks to deprecate passing various parameters
# positionally or by keyword. We just present a signature in the stub
# that describes the way users are supposed to call the constructor.
typing_extensions.sentinel.__init__


# =============================================================
# Allowlist entries that cannot or should not be fixed; <3.15
Expand Down
5 changes: 5 additions & 0 deletions stdlib/@tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion

# The runtime does some hacks to deprecate passing various parameters
# positionally or by keyword. We just present a signature in the stub
# that describes the way users are supposed to call the constructor.
typing_extensions.sentinel.__init__


# =============================================================
# Allowlist entries that cannot or should not be fixed; <3.15
Expand Down
8 changes: 5 additions & 3 deletions stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion

# The runtime does some hacks to deprecate passing various parameters
# positionally or by keyword. We just present a signature in the stub
# that describes the way users are supposed to call the constructor.
typing_extensions.sentinel.__init__


# =============================================================
# Allowlist entries that cannot or should not be fixed; <3.15
Expand Down Expand Up @@ -108,9 +113,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


# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.12
# =============================================================
Expand Down
5 changes: 5 additions & 0 deletions stdlib/@tests/stubtest_allowlists/py314.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ tkinter.simpledialog.[A-Z_]+
tkinter.simpledialog.TclVersion
tkinter.simpledialog.TkVersion

# The runtime does some hacks to deprecate passing various parameters
# positionally or by keyword. We just present a signature in the stub
# that describes the way users are supposed to call the constructor.
typing_extensions.sentinel.__init__


# =============================================================
# Allowlist entries that cannot or should not be fixed; <3.15
Expand Down
3 changes: 0 additions & 3 deletions stdlib/@tests/stubtest_allowlists/py315.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ base64.b64decode
urllib.parse.urlunparse
urllib.parse.urlunsplit

# Runtime __all__ includes no_type_check_decorator, but the attribute does not exist on Python 3.15.
typing_extensions.__all__

# Internal implementation details of the sampling profiler.
profiling.sampling.binary_collector
profiling.sampling.binary_reader
Expand Down
14 changes: 8 additions & 6 deletions stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ from _typeshed import (
from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
from os import PathLike
from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplementedType, TracebackType
from types import CellType, CodeType, EllipsisType, GenericAlias, NotImplementedType, TracebackType, UnionType

# mypy crashes if any of {ByteString, Sequence, MutableSequence, Mapping, MutableMapping}
# are imported from collections.abc in builtins.pyi
Expand Down Expand Up @@ -2185,11 +2185,13 @@ if sys.version_info >= (3, 15):
class sentinel:
__name__: str
__module__: str
def __new__(cls, name: str, /, *, repr: str | None = None) -> Self: ...
def __copy__(self, /) -> Self: ...
def __deepcopy__(self, memo: Any, /) -> Self: ...
def __or__(self, other: Any, /) -> Any: ...
def __ror__(self, other: Any, /) -> Any: ...
def __new__(cls, name: str, /, *, repr: str | None = None) -> sentinel: ...
def __copy__(self, /) -> sentinel: ...
def __deepcopy__(self, memo: Any, /) -> sentinel: ...
# `other` can be any legal form for unions.
# `x | x` creates a `sentinel` instance if `x` is a sentinel, not a `UnionType` instance.
def __or__(self, other: Any, /) -> UnionType | sentinel: ...
def __ror__(self, other: Any, /) -> UnionType | sentinel: ...

@overload
def sorted(
Expand Down
6 changes: 4 additions & 2 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,10 @@ class GenericAlias:
@property
def __typing_unpacked_tuple_args__(self) -> tuple[Any, ...] | None: ...

def __or__(self, value: Any, /) -> UnionType: ...
def __ror__(self, value: Any, /) -> UnionType: ...
# `other` can be any legal form for unions.
# `list[int] | list[int]` creates a `GenericAlias` instance, not a `UnionType` instance
def __or__(self, value: Any, /) -> UnionType | GenericAlias: ...
def __ror__(self, value: Any, /) -> UnionType | GenericAlias: ...

# GenericAlias delegates attr access to `__origin__`
def __getattr__(self, name: str) -> Any: ...
Expand Down
27 changes: 19 additions & 8 deletions stdlib/typing_extensions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ __all__ = [
"override",
"Protocol",
"Sentinel",
"sentinel",
"reveal_type",
"runtime",
"runtime_checkable",
Expand Down Expand Up @@ -680,11 +681,21 @@ else:
def type_repr(value: object) -> str: ...

# PEP 661
class Sentinel:
def __init__(self, name: str, repr: str | None = None) -> None: ...
if sys.version_info >= (3, 14):
def __or__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions
def __ror__(self, other: Any) -> UnionType: ... # other can be any type form legal for unions
else:
def __or__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions
def __ror__(self, other: Any) -> _SpecialForm: ... # other can be any type form legal for unions
if sys.version_info >= (3, 15):
from builtins import sentinel as sentinel
else:
class sentinel:
def __init__(self, name: str, /, *, repr: str | None = None) -> None: ...
__name__: str
__module__: str
if sys.version_info >= (3, 14):
# `other`` can be any type form legal for unions.
# `x | x` creates a `sentinel` instance if `x` is a sentinel, not a `UnionType` instance
def __or__(self, other: Any) -> UnionType | sentinel: ...
def __ror__(self, other: Any) -> UnionType | sentinel: ...
else:
# other can be any type form legal for unions
def __or__(self, other: Any) -> _SpecialForm: ...
def __ror__(self, other: Any) -> _SpecialForm: ...

Sentinel = sentinel
Loading