September 29th, 2024

New Typing Features in Python 3.13

Python 3.13 will enhance its typing system with features like the ReadOnly type for TypedDicts, aiming to improve code reliability and developer productivity. The final release is set for October 1, 2024.

Read original articleLink Icon
New Typing Features in Python 3.13

Python 3.13 is set to introduce several enhancements to its typing system, aimed at improving code reliability and developer productivity. Among the notable features are the new ReadOnly type, which allows developers to define items in a TypedDict as read-only, enhancing data integrity. This release builds on the robust typing system established in previous versions and is part of a broader update that includes a free-threaded mode and a Just-In-Time compiler. The final release of Python 3.13.0 is scheduled for October 1, 2024, with the current release candidate being 3.13.0rc2. The article discusses how these new typing features can streamline coding practices and elevate programming standards, providing developers with tools to write more efficient and reliable code.

- Python 3.13 introduces seven new typing features to enhance code reliability.

- A key feature is the ReadOnly type for marking TypedDict items as read-only.

- The final release of Python 3.13.0 is scheduled for October 1, 2024.

- The update also includes a free-threaded mode and a Just-In-Time compiler.

- These enhancements aim to improve developer productivity and coding practices.

Link Icon 1 comments
By @jepler - 7 months
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.