New Typing Features in Python 3.13

2 pointsposted 13 hours ago
by thunderbong

1 Comments

jepler

13 hours ago

since this is a 'walled site, you can just have a read of the official release notes and then the related PEPs ...

https://docs.python.org/3.13/whatsnew/3.13.html

New typing features:

* PEP 696: Type parameters (typing.TypeVar, typing.ParamSpec, and typing.TypeVarTuple) now support defaults.

* PEP 702: The new warnings.deprecated() decorator adds support for marking deprecations in the type system and at runtime.

* PEP 705: typing.ReadOnly can be used to mark an item of a typing.TypedDict as read-only for type checkers.

* PEP 742: typing.TypeIs provides more intuitive type narrowing behavior, as an alternative to typing.TypeGuard.

Personally the ability for the type checker to note calls to deprecated functions in a signature-dependent way looks useful. I'm sure the others will be useful too.