summaryrefslogtreecommitdiffstats
path: root/Doc/whatsnew
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-05-28 19:15:36 (GMT)
committerGitHub <noreply@github.com>2023-05-28 19:15:36 (GMT)
commit74bbc603e42d3b191358023811695d9fa4766076 (patch)
tree46e2991d0469bf0d69007973622c9b40cbb324cb /Doc/whatsnew
parent3f8d5d9ed60ae0f70c92dc29587cc6367eda80c3 (diff)
downloadcpython-74bbc603e42d3b191358023811695d9fa4766076.zip
cpython-74bbc603e42d3b191358023811695d9fa4766076.tar.gz
cpython-74bbc603e42d3b191358023811695d9fa4766076.tar.bz2
[3.12] Document PEP 698 and other new typing features in What's New (GH-104957) (#105045)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r--Doc/whatsnew/3.12.rst43
1 files changed, 37 insertions, 6 deletions
diff --git a/Doc/whatsnew/3.12.rst b/Doc/whatsnew/3.12.rst
index 7b266b2..ef9e401 100644
--- a/Doc/whatsnew/3.12.rst
+++ b/Doc/whatsnew/3.12.rst
@@ -272,7 +272,36 @@ typed dictionaries::
See :pep:`692` for more details.
-(PEP written by Franek Magiera)
+(Contributed by Franek Magiera in :gh:`103629`.)
+
+PEP 698: Override Decorator for Static Typing
+---------------------------------------------
+
+A new decorator :func:`typing.override` has been added to the :mod:`typing`
+module. It indicates to type checkers that the method is intended to override
+a method in a superclass. This allows type checkers to catch mistakes where
+a method that is intended to override something in a base class
+does not in fact do so.
+
+Example::
+
+ from typing import override
+
+ class Base:
+ def get_color(self) -> str:
+ return "blue"
+
+ class GoodChild(Base):
+ @override # ok: overrides Base.get_color
+ def get_color(self) -> str:
+ return "yellow"
+
+ class BadChild(Base):
+ @override # type checker error: does not override Base.get_color
+ def get_colour(self) -> str:
+ return "red"
+
+(Contributed by Steven Troxler in :gh:`101561`.)
.. _whatsnew312-pep695:
@@ -772,11 +801,6 @@ tempfile
typing
------
-* Add :func:`typing.override`, an override decorator telling to static type
- checkers to verify that a method overrides some method or attribute of the
- same name on a base class, as per :pep:`698`. (Contributed by Steven Troxler in
- :gh:`101564`.)
-
* :func:`isinstance` checks against
:func:`runtime-checkable protocols <typing.runtime_checkable>` now use
:func:`inspect.getattr_static` rather than :func:`hasattr` to lookup whether
@@ -821,6 +845,13 @@ typing
or more members may be slower than in Python 3.11. (Contributed by Alex
Waygood in :gh:`74690` and :gh:`103193`.)
+* All :data:`typing.TypedDict` and :data:`typing.NamedTuple` classes now have the
+ ``__orig_bases__`` attribute. (Contributed by Adrian Garcia Badaracco in
+ :gh:`103699`.)
+
+* Add ``frozen_default`` parameter to :func:`typing.dataclass_transform`.
+ (Contributed by Erik De Bonte in :gh:`99957`.)
+
sys
---