@@ -53,7 +53,7 @@ provides backports of these new features to older versions of Python.
5353 should broadly apply to most Python type checkers. (Some parts may still
5454 be specific to mypy.)
5555
56- `"Static Typing with Python" <https://typing.readthedocs.io /en/latest/ >`_
56+ `"Static Typing with Python" <https://typing.python.org /en/latest/ >`_
5757 Type-checker-agnostic documentation written by the community detailing
5858 type system features, useful typing related tools and typing best
5959 practices.
@@ -64,7 +64,7 @@ Specification for the Python Type System
6464========================================
6565
6666The canonical, up-to-date specification of the Python type system can be
67- found at `"Specification for the Python type system" <https://typing.readthedocs.io /en/latest/spec/index.html >`_.
67+ found at `"Specification for the Python type system" <https://typing.python.org /en/latest/spec/index.html >`_.
6868
6969.. _type-aliases :
7070
@@ -1086,7 +1086,7 @@ Special forms
10861086These can be used as types in annotations. They all support subscription using
10871087``[] ``, but each has a unique syntax.
10881088
1089- .. data :: Union
1089+ .. class :: Union
10901090
10911091 Union type; ``Union[X, Y] `` is equivalent to ``X | Y `` and means either X or Y.
10921092
@@ -1121,6 +1121,14 @@ These can be used as types in annotations. They all support subscription using
11211121 Unions can now be written as ``X | Y ``. See
11221122 :ref: `union type expressions<types-union> `.
11231123
1124+ .. versionchanged :: 3.14
1125+ :class: `types.UnionType ` is now an alias for :class: `Union `, and both
1126+ ``Union[int, str] `` and ``int | str `` create instances of the same class.
1127+ To check whether an object is a ``Union `` at runtime, use
1128+ ``isinstance(obj, Union) ``. For compatibility with earlier versions of
1129+ Python, use
1130+ ``get_origin(obj) is typing.Union or get_origin(obj) is types.UnionType ``.
1131+
11241132.. data :: Optional
11251133
11261134 ``Optional[X] `` is equivalent to ``X | None `` (or ``Union[X, None] ``).
@@ -2292,6 +2300,20 @@ without the dedicated syntax, as documented below.
22922300
22932301 .. versionadded :: 3.14
22942302
2303+ .. rubric :: Unpacking
2304+
2305+ Type aliases support star unpacking using the ``*Alias `` syntax.
2306+ This is equivalent to using ``Unpack[Alias] `` directly:
2307+
2308+ .. doctest ::
2309+
2310+ >>> type Alias = tuple[int , str ]
2311+ >>> type Unpacked = tuple[bool , * Alias]
2312+ >>> Unpacked.__value__
2313+ tuple[bool, typing.Unpack[Alias]]
2314+
2315+ .. versionadded :: next
2316+
22952317
22962318Other special directives
22972319""""""""""""""""""""""""
@@ -2376,6 +2398,10 @@ types.
23762398 .. versionchanged :: 3.11
23772399 Added support for generic namedtuples.
23782400
2401+ .. versionchanged :: next
2402+ Using :func: `super ` (and the ``__class__ `` :term: `closure variable `) in methods of ``NamedTuple `` subclasses
2403+ is unsupported and causes a :class: `TypeError `.
2404+
23792405 .. deprecated-removed :: 3.13 3.15
23802406 The undocumented keyword argument syntax for creating NamedTuple classes
23812407 (``NT = NamedTuple("NT", x=int) ``) is deprecated, and will be disallowed
@@ -2890,7 +2916,7 @@ Functions and decorators
28902916
28912917 .. seealso ::
28922918 `Unreachable Code and Exhaustiveness Checking
2893- <https://typing.readthedocs.io /en/latest/guides/unreachable.html> `__ has more
2919+ <https://typing.python.org /en/latest/guides/unreachable.html> `__ has more
28942920 information about exhaustiveness checking with static typing.
28952921
28962922 .. versionadded :: 3.11
0 commit comments