Skip to content

Commit 29473d1

Browse files
committed
Merge remote-tracking branch 'upstream/main' into test-coverage
2 parents ed5ee71 + 944a351 commit 29473d1

6 files changed

Lines changed: 90 additions & 68 deletions

File tree

.github/workflows/third_party.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ jobs:
299299
matrix:
300300
# PyPy is deliberately omitted here, since SQLAlchemy's tests
301301
# fail on PyPy for reasons unrelated to typing_extensions.
302-
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
302+
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
303303
checkout-ref: [ "main", "rel_2_0" ]
304304
# sqlalchemy tests fail when using the Ubuntu 24.04 runner
305305
# https://github.com/sqlalchemy/sqlalchemy/commit/8d73205f352e68c6603e90494494ef21027ec68f

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
`typing_extensions` implementation has raised an error on Python 3.10+ since
66
`typing_extensions` v4.6.0. Patch by Brian Schubert.
77

8+
# Release 4.15.0 (August 25, 2025)
9+
10+
No user-facing changes since 4.15.0rc1.
11+
812
# Release 4.15.0rc1 (August 18, 2025)
913

1014
- Add the `@typing_extensions.disjoint_base` decorator, as specified

doc/conf.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@
3838

3939
html_theme = 'alabaster'
4040

41+
html_theme_options = {
42+
"description": "Backported and experimental type hints for Python",
43+
# Make the sidebar "sticky" so that is stays visible when scrolling.
44+
# Also makes the sidebar appear at the top of the page on mobile.
45+
"fixed_sidebar": True,
46+
}
47+
48+
html_sidebars = {
49+
'**': [
50+
'about.html',
51+
'searchfield.html',
52+
'localtoc.html',
53+
]
54+
}
55+
56+
# Don't include object entries (e.g. functions, classes) in the table of contents.
57+
toc_object_entries = False
4158

4259
class MyTranslator(HTML5Translator):
4360
"""Adds a link target to name without `typing_extensions.` prefix."""

doc/index.rst

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ Special typing primitives
259259

260260
.. versionadded:: 4.12.0
261261

262+
.. data:: NoExtraItems
263+
264+
A sentinel used when the ``extra_items`` class argument to :class:`TypedDict` is not
265+
provided. In ``typing`` since 3.15.
266+
267+
.. versionadded:: 4.13.0
268+
262269
.. data:: NotRequired
263270

264271
See :py:data:`typing.NotRequired` and :pep:`655`. In ``typing`` since 3.11.
@@ -387,12 +394,13 @@ Special typing primitives
387394

388395
.. versionadded:: 4.10.0
389396

390-
.. class:: TypedDict(dict, total=True)
391-
392-
See :py:class:`typing.TypedDict` and :pep:`589`. In ``typing`` since 3.8.
397+
.. class:: TypedDict(dict, total=True, closed=False, extra_items=<no extra items>)
393398

399+
See :py:class:`typing.TypedDict` and :pep:`589`. In ``typing`` since 3.8, but
400+
changed and enhanced in several ways since then.
394401
``typing_extensions`` backports various bug fixes and improvements
395-
to ``TypedDict`` on Python 3.11 and lower.
402+
to ``TypedDict``.
403+
396404
:py:class:`TypedDict` does not store runtime information
397405
about which (if any) keys are non-required in Python 3.8, and does not
398406
honor the ``total`` keyword with old-style ``TypedDict()`` in Python
@@ -426,35 +434,23 @@ Special typing primitives
426434

427435
.. versionadded:: 4.9.0
428436

429-
The experimental ``closed`` keyword argument and the special key
430-
``__extra_items__`` proposed in :pep:`728` are supported.
431-
432-
When ``closed`` is unspecified or ``closed=False`` is given,
433-
``__extra_items__`` behaves like a regular key. Otherwise, this becomes a
434-
special key that does not show up in ``__readonly_keys__``,
435-
``__mutable_keys__``, ``__required_keys__``, ``__optional_keys``, or
436-
``__annotations__``.
437+
The ``closed`` and ``extra_items`` keyword arguments introduced by
438+
:pep:`728` and supported in Python 3.15 and newer are supported.
437439

438440
For runtime introspection, two attributes can be looked at:
439441

440442
.. attribute:: __closed__
441443

442444
A boolean flag indicating whether the current ``TypedDict`` is
443-
considered closed. This is not inherited by the ``TypedDict``'s
444-
subclasses.
445+
considered closed. This reflects the ``closed`` class argument.
445446

446447
.. versionadded:: 4.10.0
447448

448449
.. attribute:: __extra_items__
449450

450-
The type annotation of the extra items allowed on the ``TypedDict``.
451-
This attribute defaults to ``None`` on a TypedDict that has itself and
452-
all its bases non-closed. This default is different from ``type(None)``
453-
that represents ``__extra_items__: None`` defined on a closed
454-
``TypedDict``.
455-
456-
If ``__extra_items__`` is not defined or inherited on a closed
457-
``TypedDict``, this defaults to ``Never``.
451+
The type of the extra items allowed on the ``TypedDict``.
452+
This attribute defaults to :data:`NoExtraItems` if the ``extra_items``
453+
class argument is not provided.
458454

459455
.. versionadded:: 4.10.0
460456

@@ -495,6 +491,16 @@ Special typing primitives
495491
The keyword argument ``closed`` and the special key ``__extra_items__``
496492
when ``closed=True`` is given were supported.
497493

494+
.. versionchanged:: 4.13.0
495+
496+
:pep:`728` support was updated to a newer version. Extra items are now
497+
indicated with an ``extra_items`` class argument, not a special key
498+
``__extra_items__``.
499+
500+
A value assigned to ``__total__`` in the class body of a
501+
``TypedDict`` will be overwritten by the ``total`` argument of the
502+
``TypedDict`` constructor.
503+
498504
.. class:: TypeVar(name, *constraints, bound=None, covariant=False,
499505
contravariant=False, infer_variance=False, default=NoDefault)
500506

@@ -696,7 +702,8 @@ Decorators
696702

697703
.. decorator:: deprecated(msg, *, category=DeprecationWarning, stacklevel=1)
698704

699-
See :pep:`702`. In the :mod:`warnings` module since Python 3.13.
705+
See :py:func:`warnings.deprecated` and :pep:`702`. In the :mod:`warnings` module
706+
since Python 3.13.
700707

701708
.. versionadded:: 4.5.0
702709

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
66
# Project metadata
77
[project]
88
name = "typing_extensions"
9-
version = "4.15.0rc1"
9+
version = "4.15.0"
1010
description = "Backported and Experimental Type Hints for Python 3.9+"
1111
readme = "README.md"
1212
requires-python = ">=3.9"
@@ -123,6 +123,7 @@ known-first-party = ["typing_extensions", "_typed_dict_test_helper"]
123123

124124
[tool.coverage.report]
125125
fail_under = 96
126+
precision = 2
126127
show_missing = true
127128
# Omit files that are created in temporary directories during tests.
128129
# If not explicitly omitted they will result in warnings in the report.

src/typing_extensions.py

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,48 @@
160160
# Added with bpo-45166 to 3.10.1+ and some 3.9 versions
161161
_FORWARD_REF_HAS_CLASS = "__forward_is_class__" in typing.ForwardRef.__slots__
162162

163-
# The functions below are modified copies of typing internal helpers.
164-
# They are needed by _ProtocolMeta and they provide support for PEP 646.
163+
class Sentinel:
164+
"""Create a unique sentinel object.
165+
166+
*name* should be the name of the variable to which the return value shall be assigned.
165167
168+
*repr*, if supplied, will be used for the repr of the sentinel object.
169+
If not provided, "<name>" will be used.
170+
"""
171+
172+
def __init__(
173+
self,
174+
name: str,
175+
repr: typing.Optional[str] = None,
176+
):
177+
self._name = name
178+
self._repr = repr if repr is not None else f'<{name}>'
166179

167-
class _Sentinel:
168180
def __repr__(self):
169-
return "<sentinel>"
181+
return self._repr
182+
183+
if sys.version_info < (3, 11):
184+
# The presence of this method convinces typing._type_check
185+
# that Sentinels are types.
186+
def __call__(self, *args, **kwargs):
187+
raise TypeError(f"{type(self).__name__!r} object is not callable")
170188

189+
# Breakpoint: https://github.com/python/cpython/pull/21515
190+
if sys.version_info >= (3, 10):
191+
def __or__(self, other):
192+
return typing.Union[self, other]
193+
194+
def __ror__(self, other):
195+
return typing.Union[other, self]
196+
197+
def __getstate__(self):
198+
raise TypeError(f"Cannot pickle {type(self).__name__!r} object")
171199

172-
_marker = _Sentinel()
173200

201+
_marker = Sentinel("sentinel")
202+
203+
# The functions below are modified copies of typing internal helpers.
204+
# They are needed by _ProtocolMeta and they provide support for PEP 646.
174205

175206
# Breakpoint: https://github.com/python/cpython/pull/27342
176207
if sys.version_info >= (3, 10):
@@ -4206,44 +4237,6 @@ def evaluate_forward_ref(
42064237
)
42074238

42084239

4209-
class Sentinel:
4210-
"""Create a unique sentinel object.
4211-
4212-
*name* should be the name of the variable to which the return value shall be assigned.
4213-
4214-
*repr*, if supplied, will be used for the repr of the sentinel object.
4215-
If not provided, "<name>" will be used.
4216-
"""
4217-
4218-
def __init__(
4219-
self,
4220-
name: str,
4221-
repr: typing.Optional[str] = None,
4222-
):
4223-
self._name = name
4224-
self._repr = repr if repr is not None else f'<{name}>'
4225-
4226-
def __repr__(self):
4227-
return self._repr
4228-
4229-
if sys.version_info < (3, 11):
4230-
# The presence of this method convinces typing._type_check
4231-
# that Sentinels are types.
4232-
def __call__(self, *args, **kwargs):
4233-
raise TypeError(f"{type(self).__name__!r} object is not callable")
4234-
4235-
# Breakpoint: https://github.com/python/cpython/pull/21515
4236-
if sys.version_info >= (3, 10):
4237-
def __or__(self, other):
4238-
return typing.Union[self, other]
4239-
4240-
def __ror__(self, other):
4241-
return typing.Union[other, self]
4242-
4243-
def __getstate__(self):
4244-
raise TypeError(f"Cannot pickle {type(self).__name__!r} object")
4245-
4246-
42474240
if sys.version_info >= (3, 14, 0, "beta"):
42484241
type_repr = annotationlib.type_repr
42494242
else:

0 commit comments

Comments
 (0)