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.NoDefaultsentinel 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, matchingtyping.TypeVar,typing.ParamSpecand
typing.TypeVarTupleon Python 3.13+. - TypeVars, ParamSpecs and TypeVarTuples with
default=Nonepassed to
their constructors now have their__default__attribute set toNone
at runtime rather thantypes.NoneType. - Fix most tests for
TypeVar,ParamSpecandTypeVarTupleon 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
TypeVarwith a default value after a
TypeVarTuplein 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.
- Backport the
- Fix
Protocoltests 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
AttributeErrorwhen usingtyping_extensions.runtime_checkable
in combination withtyping.Protocolon Python 3.12.2 or newer.
Patch by Alex Waygood. - At runtime,
assert_nevernow includes the repr of the argument
in theAssertionError. 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 oftyping_extensions.AsyncGenerator,
now default toNone. This matches the behaviour oftyping.Generator
andtyping.AsyncGeneratoron Python 3.13+. typing_extensions.ContextManagerand
typing_extensions.AsyncContextManagernow have an optional second
parameter, which defaults toOptional[bool]. The new parameter
signifies the return type of the__(a)exit__method, matching
typing.ContextManagerandtyping.AsyncContextManageron Python
3.13+.- Backport
types.CapsuleTypefrom Python 3.13. - Releases are now made using Trusted Publishers
improving the security of the release process. Patch by Jelle Zijlstra.