Skip to content

Commit 6b51773

Browse files
JelleZijlstrahauntsaninjaAlexWaygood
authored
gh-91491: Complete Whats New in 3.11 for typing (#92708)
Fixes #91491 Co-authored-by: Shantanu <[email protected]> Co-authored-by: Alex Waygood <[email protected]>
1 parent c5f5f97 commit 6b51773

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

Doc/whatsnew/3.11.rst

+36-4
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,12 @@ For major changes, see :ref:`new-feat-related-type-hints-311`.
730730
the given type. At runtime it simply returns the received value.
731731
(Contributed by Jelle Zijlstra in :gh:`90638`.)
732732

733+
* :data:`typing.TypedDict` types can now be generic. (Contributed by
734+
Samodya Abey in :gh:`89026`.)
735+
736+
* :class:`~typing.NamedTuple` types can now be generic.
737+
(Contributed by Serhiy Storchaka in :issue:`43923`.)
738+
733739
* Allow subclassing of :class:`typing.Any`. This is useful for avoiding
734740
type checker errors related to highly dynamic class, such as mocks.
735741
(Contributed by Shantanu Jain in :gh:`91154`.)
@@ -743,11 +749,33 @@ For major changes, see :ref:`new-feat-related-type-hints-311`.
743749
to clear all registered overloads of a function.
744750
(Contributed by Jelle Zijlstra in :gh:`89263`.)
745751

746-
* :data:`typing.TypedDict` subclasses can now be generic. (Contributed by
747-
Samodya Abey in :gh:`89026`.)
752+
* The :meth:`__init__` method of :class:`~typing.Protocol` subclasses
753+
is now preserved. (Contributed by Adrian Garcia Badarasco in :gh:`88970`.)
748754

749-
* :class:`~typing.NamedTuple` subclasses can now be generic.
750-
(Contributed by Serhiy Storchaka in :issue:`43923`.)
755+
* The representation of empty tuple types (``Tuple[()]``) is simplified.
756+
This affects introspection, e.g. ``get_args(Tuple[()])`` now evaluates
757+
to ``()`` instead of ``((),)``.
758+
(Contributed by Serhiy Storchaka in :gh:`91137`.)
759+
760+
* Loosen runtime requirements for type annotations by removing the callable
761+
check in the private ``typing._type_check`` function. (Contributed by
762+
Gregory Beauregard in :gh:`90802`.)
763+
764+
* :func:`typing.get_type_hints` now supports evaluating strings as forward
765+
references in :ref:`PEP 585 generic aliases <types-genericalias>`.
766+
(Contributed by Niklas Rosenstein in :gh:`85542`.)
767+
768+
* :func:`typing.get_type_hints` no longer adds :data:`~typing.Optional`
769+
to parameters with ``None`` as a default. (Contributed by Nikita Sobolev
770+
in :gh:`90353`.)
771+
772+
* :func:`typing.get_type_hints` now supports evaluating bare stringified
773+
:data:`~typing.ClassVar` annotations. (Contributed by Gregory Beauregard
774+
in :gh:`90711`.)
775+
776+
* :func:`typing.no_type_check` no longer modifies external classes and functions.
777+
It also now correctly marks classmethods as not to be type checked. (Contributed
778+
by Nikita Sobolev in :gh:`90729`.)
751779

752780

753781
tkinter
@@ -1236,6 +1264,10 @@ Deprecated
12361264
wherever possible.
12371265
(Contributed by Alex Waygood in :gh:`92332`.)
12381266

1267+
* The keyword argument syntax for constructing :data:`~typing.TypedDict` types
1268+
is now deprecated. Support will be removed in Python 3.13. (Contributed by
1269+
Jingchen Ye in :gh:`90224`.)
1270+
12391271

12401272
Pending Removal in Python 3.12
12411273
==============================

0 commit comments

Comments
 (0)