Skip to content

Releases: python/typing_extensions

4.13.2

10 Apr 14:17
4525e9d
Compare
Choose a tag to compare
  • Fix TypeError when taking the union of typing_extensions.TypeAliasType and a
    typing.TypeAliasType on Python 3.12 and 3.13.
    Patch by Joren Hammudoglu.
  • Backport from CPython PR #132160
    to avoid having user arguments shadowed in generated __new__ by
    @typing_extensions.deprecated.
    Patch by Victorien Plot.

4.13.1

03 Apr 16:07
45a8847
Compare
Choose a tag to compare

This is a bugfix release fixing two edge cases that appear on old bugfix releases of CPython.

Bugfixes:

  • Fix regression in 4.13.0 on Python 3.10.2 causing a TypeError when using Concatenate.
    Patch by Daraan.
  • Fix TypeError when using evaluate_forward_ref on Python 3.10.1-2 and 3.9.8-10.
    Patch by Daraan.

4.13.0

26 Mar 03:46
c893401
Compare
Choose a tag to compare

New features:

  • Add typing_extensions.TypeForm from PEP 747. Patch by
    Jelle Zijlstra.
  • Add typing_extensions.get_annotations, a backport of
    inspect.get_annotations that adds features specified
    by PEP 649. Patches by Jelle Zijlstra and Alex Waygood.
  • Backport evaluate_forward_ref from CPython PR
    #119891 to evaluate ForwardRefs.
    Patch by Daraan, backporting a CPython PR by Jelle Zijlstra.

Bugfixes and changed features:

  • Update PEP 728 implementation to a newer version of the PEP. Patch by Jelle Zijlstra.
  • Copy the coroutine status of functions and methods wrapped
    with @typing_extensions.deprecated. Patch by Sebastian Rittau.
  • Fix bug where TypeAliasType instances could be subscripted even
    where they were not generic. Patch by Daraan.
  • Fix bug where a subscripted TypeAliasType instance did not have all
    attributes of the original TypeAliasType instance on older Python versions.
    Patch by Daraan and Alex Waygood.
  • Fix bug where subscripted TypeAliasType instances (and some other
    subscripted objects) had wrong parameters if they were directly
    subscripted with an Unpack object.
    Patch by Daraan.
  • Backport to Python 3.10 the ability to substitute ... in generic Callable
    aliases that have a Concatenate special form as their argument.
    Patch by Daraan.
  • Extended the Concatenate backport for Python 3.8-3.10 to now accept
    Ellipsis as an argument. Patch by Daraan.
  • Fix backport of get_type_hints to reflect Python 3.11+ behavior which does not add
    Union[..., NoneType] to annotations that have a None default value anymore.
    This fixes wrapping of Annotated in an unwanted Optional in such cases.
    Patch by Daraan.
  • Fix error in subscription of Unpack aliases causing nested Unpacks
    to not be resolved correctly. Patch by Daraan.
  • Backport CPython PR #124795:
    fix TypeAliasType not raising an error on non-tuple inputs for type_params.
    Patch by Daraan.
  • Fix that lists and ... could not be used for parameter expressions for TypeAliasType
    instances before Python 3.11.
    Patch by Daraan.
  • Fix error on Python 3.10 when using typing.Concatenate and
    typing_extensions.Concatenate together. Patch by Daraan.
  • Backport of CPython PR #109544
    to reflect Python 3.13+ behavior: A value assigned to __total__ in the class body of a
    TypedDict will be overwritten by the total argument of the TypedDict constructor.
    Patch by Daraan, backporting a CPython PR by Jelle Zijlstra.
  • isinstance(typing_extensions.Unpack[...], TypeVar) now evaluates to False on Python 3.11
    and newer, but remains True on versions before 3.11.
    Patch by Daraan.

4.13.0rc1

18 Mar 18:02
3c66d26
Compare
Choose a tag to compare
4.13.0rc1 Pre-release
Pre-release

New features:

  • Add typing_extensions.TypeForm from PEP 747. Patch by
    Jelle Zijlstra.
  • Add typing_extensions.get_annotations, a backport of
    inspect.get_annotations that adds features specified
    by PEP 649. Patches by Jelle Zijlstra and Alex Waygood.
  • Backport evaluate_forward_ref from CPython PR
    #119891 to evaluate ForwardRefs.
    Patch by Daraan, backporting a CPython PR by Jelle Zijlstra.

Bugfixes and changed features:

  • Update PEP 728 implementation to a newer version of the PEP. Patch by Jelle Zijlstra.
  • Copy the coroutine status of functions and methods wrapped
    with @typing_extensions.deprecated. Patch by Sebastian Rittau.
  • Fix bug where TypeAliasType instances could be subscripted even
    where they were not generic. Patch by Daraan.
  • Fix bug where a subscripted TypeAliasType instance did not have all
    attributes of the original TypeAliasType instance on older Python versions.
    Patch by Daraan and Alex Waygood.
  • Fix bug where subscripted TypeAliasType instances (and some other
    subscripted objects) had wrong parameters if they were directly
    subscripted with an Unpack object.
    Patch by Daraan.
  • Backport to Python 3.10 the ability to substitute ... in generic Callable
    aliases that have a Concatenate special form as their argument.
    Patch by Daraan.
  • Extended the Concatenate backport for Python 3.8-3.10 to now accept
    Ellipsis as an argument. Patch by Daraan.
  • Fix backport of get_type_hints to reflect Python 3.11+ behavior which does not add
    Union[..., NoneType] to annotations that have a None default value anymore.
    This fixes wrapping of Annotated in an unwanted Optional in such cases.
    Patch by Daraan.
  • Fix error in subscription of Unpack aliases causing nested Unpacks
    to not be resolved correctly. Patch by Daraan.
  • Backport CPython PR #124795:
    fix TypeAliasType not raising an error on non-tuple inputs for type_params.
    Patch by Daraan.
  • Fix that lists and ... could not be used for parameter expressions for TypeAliasType
    instances before Python 3.11.
    Patch by Daraan.
  • Fix error on Python 3.10 when using typing.Concatenate and
    typing_extensions.Concatenate together. Patch by Daraan.
  • Backport of CPython PR #109544
    to reflect Python 3.13+ behavior: A value assigned to __total__ in the class body of a
    TypedDict will be overwritten by the total argument of the TypedDict constructor.
    Patch by Daraan, backporting a CPython PR by Jelle Zijlstra.
  • Fix for Python 3.11 that now isinstance(typing_extensions.Unpack[...], TypeVar)
    evaluates to False, however still True for <3.11.
    Patch by Daraan

4.12.2

07 Jun 18:50
e1250ff
Compare
Choose a tag to compare
  • Fix regression in v4.12.0 where specialization of certain generics with an overridden __eq__ method would raise errors. Patch by Jelle Zijlstra.
  • Fix tests so they pass on 3.13.0b2

4.12.1

01 Jun 17:27
7269638
Compare
Choose a tag to compare
  • Preliminary changes for compatibility with the draft implementation
    of PEP 649 in Python 3.14. Patch by Jelle Zijlstra.
  • Fix regression in v4.12.0 where nested Annotated types would cause
    TypeError to be raised if the nested Annotated type had unhashable
    metadata. Patch by Alex Waygood.

4.12.0

24 May 00:23
f90a8dc
Compare
Choose a tag to compare

This release focuses on compatibility with the upcoming release of
Python 3.13. Most changes are related to the implementation of type
parameter defaults (PEP 696).

Thanks to all of the people who contributed patches, especially Alex
Waygood, who did most of the work adapting typing-extensions to the
CPython PEP 696 implementation.

There is a single change since 4.12.0rc1:

  • Fix incorrect behaviour of typing_extensions.ParamSpec on Python 3.8 and
    3.9 that meant that
    isinstance(typing_extensions.ParamSpec("P"), typing.TypeVar) would have a
    different result in some situations depending on whether or not a profiling
    function had been set using sys.setprofile. Patch by Alex Waygood.

Changes included in 4.12.0rc1:

  • Improve the implementation of type parameter defaults (PEP 696)
    • Backport the typing.NoDefault sentinel object from Python 3.13.
      TypeVars, ParamSpecs and TypeVarTuples without default values now have
      their __default__ attribute set to this sentinel value.
    • TypeVars, ParamSpecs and TypeVarTuples now have a has_default()
      method, matching typing.TypeVar, typing.ParamSpec and
      typing.TypeVarTuple on Python 3.13+.
    • TypeVars, ParamSpecs and TypeVarTuples with default=None passed to
      their constructors now have their __default__ attribute set to None
      at runtime rather than types.NoneType.
    • Fix most tests for TypeVar, ParamSpec and TypeVarTuple on Python
      3.13.0b1 and newer.
    • Backport CPython PR #118774,
      allowing type parameters without default values to follow those with
      default values in some type parameter lists. Patch by Alex Waygood,
      backporting a CPython PR by Jelle Zijlstra.
    • It is now disallowed to use a TypeVar with a default value after a
      TypeVarTuple in a type parameter list. This matches the CPython
      implementation of PEP 696 on Python 3.13+.
    • Fix bug in PEP-696 implementation where a default value for a ParamSpec
      would be cast to a tuple if a list was provided.
      Patch by Alex Waygood.
  • Fix Protocol tests on Python 3.13.0a6 and newer. 3.13.0a6 adds a new
    __static_attributes__ attribute to all classes in Python,
    which broke some assumptions made by the implementation of
    typing_extensions.Protocol. Similarly, 3.13.0b1 adds the new
    __firstlineno__ attribute to all classes.
  • Fix AttributeError when using typing_extensions.runtime_checkable
    in combination with typing.Protocol on Python 3.12.2 or newer.
    Patch by Alex Waygood.
  • At runtime, assert_never now includes the repr of the argument
    in the AssertionError. Patch by Hashem, backporting of the original
    fix python/cpython#91720 by Jelle Zijlstra.
  • The second and third parameters of typing_extensions.Generator,
    and the second parameter of typing_extensions.AsyncGenerator,
    now default to None. This matches the behaviour of typing.Generator
    and typing.AsyncGenerator on Python 3.13+.
  • typing_extensions.ContextManager and
    typing_extensions.AsyncContextManager now have an optional second
    parameter, which defaults to Optional[bool]. The new parameter
    signifies the return type of the __(a)exit__ method, matching
    typing.ContextManager and typing.AsyncContextManager on Python
    3.13+.
  • Backport types.CapsuleType from Python 3.13.
  • Releases are now made using Trusted Publishers
    improving the security of the release process. Patch by Jelle Zijlstra.

4.12.0rc1

16 May 19:57
0dbc7c9
Compare
Choose a tag to compare
4.12.0rc1 Pre-release
Pre-release

This release focuses on compatibility with the upcoming release of
Python 3.13. Most changes are related to the implementation of type
parameter defaults (PEP 696).

Thanks to all of the people who contributed patches, especially Alex
Waygood, who did most of the work adapting typing-extensions to the
CPython PEP 696 implementation.

Full changelog:

  • Improve the implementation of type parameter defaults (PEP 696)
    • Backport the typing.NoDefault sentinel object from Python 3.13.
      TypeVars, ParamSpecs and TypeVarTuples without default values now have
      their __default__ attribute set to this sentinel value.
    • TypeVars, ParamSpecs and TypeVarTuples now have a has_default()
      method, matching typing.TypeVar, typing.ParamSpec and
      typing.TypeVarTuple on Python 3.13+.
    • TypeVars, ParamSpecs and TypeVarTuples with default=None passed to
      their constructors now have their __default__ attribute set to None
      at runtime rather than types.NoneType.
    • Fix most tests for TypeVar, ParamSpec and TypeVarTuple on Python
      3.13.0b1 and newer.
    • Backport CPython PR #118774,
      allowing type parameters without default values to follow those with
      default values in some type parameter lists. Patch by Alex Waygood,
      backporting a CPython PR by Jelle Zijlstra.
    • It is now disallowed to use a TypeVar with a default value after a
      TypeVarTuple in a type parameter list. This matches the CPython
      implementation of PEP 696 on Python 3.13+.
    • Fix bug in PEP-696 implementation where a default value for a ParamSpec
      would be cast to a tuple if a list was provided.
      Patch by Alex Waygood.
  • Fix Protocol tests on Python 3.13.0a6 and newer. 3.13.0a6 adds a new
    __static_attributes__ attribute to all classes in Python,
    which broke some assumptions made by the implementation of
    typing_extensions.Protocol. Similarly, 3.13.0b1 adds the new
    __firstlineno__ attribute to all classes.
  • Fix AttributeError when using typing_extensions.runtime_checkable
    in combination with typing.Protocol on Python 3.12.2 or newer.
    Patch by Alex Waygood.
  • At runtime, assert_never now includes the repr of the argument
    in the AssertionError. Patch by Hashem, backporting of the original
    fix python/cpython#91720 by Jelle Zijlstra.
  • The second and third parameters of typing_extensions.Generator,
    and the second parameter of typing_extensions.AsyncGenerator,
    now default to None. This matches the behaviour of typing.Generator
    and typing.AsyncGenerator on Python 3.13+.
  • typing_extensions.ContextManager and
    typing_extensions.AsyncContextManager now have an optional second
    parameter, which defaults to Optional[bool]. The new parameter
    signifies the return type of the __(a)exit__ method, matching
    typing.ContextManager and typing.AsyncContextManager on Python
    3.13+.
  • Backport types.CapsuleType from Python 3.13.
  • Releases are now made using Trusted Publishers
    improving the security of the release process. Patch by Jelle Zijlstra.

4.12.0a2

16 May 19:19
72298f0
Compare
Choose a tag to compare
4.12.0a2 Pre-release
Pre-release

This is another alpha release to test the new release workflow.

4.12.0a1

16 May 19:09
21fde1f
Compare
Choose a tag to compare
4.12.0a1 Pre-release
Pre-release

This release primarily tests a revised release workflow. If all goes
well, release 4.12.0rc1 will follow soon.

  • Backport the typing.NoDefault sentinel object from Python 3.13.
    TypeVars, ParamSpecs and TypeVarTuples without default values now have
    their __default__ attribute set to this sentinel value.
  • TypeVars, ParamSpecs and TypeVarTuples now have a has_default()
    method, matching typing.TypeVar, typing.ParamSpec and
    typing.TypeVarTuple on Python 3.13+.
  • TypeVars, ParamSpecs and TypeVarTuples with default=None passed to
    their constructors now have their __default__ attribute set to None
    at runtime rather than types.NoneType.
  • Fix most tests for TypeVar, ParamSpec and TypeVarTuple on Python
    3.13.0b1 and newer.
  • Backport CPython PR #118774,
    allowing type parameters without default values to follow those with
    default values in some type parameter lists. Patch by Alex Waygood,
    backporting a CPython PR by Jelle Zijlstra.
  • It is now disallowed to use a TypeVar with a default value after a
    TypeVarTuple in a type parameter list. This matches the CPython
    implementation of PEP 696 on Python 3.13+.
  • Fix bug in PEP-696 implementation where default values for ParamSpecs
    would be cast to tuples if a list was provided as the default value.
    Patch by Alex Waygood.
  • Fix Protocol tests on Python 3.13.0a6 and newer. 3.13.0a6 adds a new
    __static_attributes__ attribute to all classes in Python,
    which broke some assumptions made by the implementation of
    typing_extensions.Protocol. Similarly, 3.13.0b1 adds the new
    __firstlineno__ attribute to all classes.
  • Fix AttributeError when using typing_extensions.runtime_checkable
    in combination with typing.Protocol on Python 3.12.2 or newer.
    Patch by Alex Waygood.
  • At runtime, assert_never now includes the repr of the argument
    in the AssertionError. Patch by Hashem, backporting of the original
    fix python/cpython#91720 by Jelle Zijlstra.
  • The second and third parameters of typing_extensions.Generator,
    and the second parameter of typing_extensions.AsyncGenerator,
    now default to None. This matches the behaviour of typing.Generator
    and typing.AsyncGenerator on Python 3.13+.
  • typing_extensions.ContextManager and
    typing_extensions.AsyncContextManager now have an optional second
    parameter, which defaults to Optional[bool]. The new parameter
    signifies the return type of the __(a)exit__ method, matching
    typing.ContextManager and typing.AsyncContextManager on Python
    3.13+.
  • Backport types.CapsuleType from Python 3.13.