From 6c494a4335d326d94ab512ebb192c702faeaa567 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Sat, 1 Jul 2023 16:55:40 +0100 Subject: [PATCH 1/3] gh-106309: Deprecate typing.no_type_check_decorator --- Doc/library/typing.rst | 3 +++ Doc/whatsnew/3.13.rst | 4 ++++ Lib/test/test_typing.py | 13 ++++++++++--- Lib/typing.py | 2 ++ .../2023-07-01-16-51-55.gh-issue-106309.hSlB17.rst | 2 ++ 5 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2023-07-01-16-51-55.gh-issue-106309.hSlB17.rst diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 7ac1062eb26d7c..b168e4467a4321 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -2844,6 +2844,9 @@ Functions and decorators This wraps the decorator with something that wraps the decorated function in :func:`no_type_check`. + .. deprecated-removed:: 3.13 3.15 + No type checker ever added support for ``@no_type_check_decorator``. It + is therefore deprecated, and will be removed in Python 3.15. .. decorator:: override diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 9696dd4ff0b700..d0dbe9a78d2fca 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -160,6 +160,10 @@ Deprecated ``NT = NamedTuple("NT", [])``. To create a TypedDict class with 0 fields, use ``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``. (Contributed by Alex Waygood in :gh:`105566` and :gh:`105570`.) +* :func:`typing.no_type_check_decorator` is deprecated, and scheduled for + removal in Python 3.15. After eight years in the :mod:`typing` module, it + has yet to be supported by any major type checkers. + (Contributed by Alex Waygood in :gh:`106309`.) * :mod:`array`'s ``'u'`` format code, deprecated in docs since Python 3.3, emits :exc:`DeprecationWarning` since 3.13 diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 1df21926d1f67e..02bd7d940fcc61 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -5795,9 +5795,16 @@ class F: def test_meta_no_type_check(self): - @no_type_check_decorator - def magic_decorator(func): - return func + with self.assertWarnsRegex( + DeprecationWarning, + ( + "'typing.no_type_check_decorator' is deprecated " + "and slated for removal in Python 3.15" + ) + ): + @no_type_check_decorator + def magic_decorator(func): + return func self.assertEqual(magic_decorator.__name__, 'magic_decorator') diff --git a/Lib/typing.py b/Lib/typing.py index 9187b74b0e2e1f..387b4c5ad5284b 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -2395,6 +2395,8 @@ def no_type_check_decorator(decorator): This wraps the decorator with something that wraps the decorated function in @no_type_check. """ + import warnings + warnings._deprecated("typing.no_type_check_decorator", remove=(3, 15)) @functools.wraps(decorator) def wrapped_decorator(*args, **kwds): func = decorator(*args, **kwds) diff --git a/Misc/NEWS.d/next/Library/2023-07-01-16-51-55.gh-issue-106309.hSlB17.rst b/Misc/NEWS.d/next/Library/2023-07-01-16-51-55.gh-issue-106309.hSlB17.rst new file mode 100644 index 00000000000000..5bd3880520871f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2023-07-01-16-51-55.gh-issue-106309.hSlB17.rst @@ -0,0 +1,2 @@ +Deprecate :func:`typing.no_type_check_decorator`. No major type checker ever +added support for this decorator. Patch by Alex Waygood. From 53dbad05e88112c352188bb8a68e7c301dc6d62c Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sat, 1 Jul 2023 16:57:43 +0100 Subject: [PATCH 2/3] formatting nit --- Lib/test/test_typing.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 02bd7d940fcc61..0450a87577ecea 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -5794,14 +5794,11 @@ class F: get_type_hints(clazz) def test_meta_no_type_check(self): - - with self.assertWarnsRegex( - DeprecationWarning, - ( - "'typing.no_type_check_decorator' is deprecated " - "and slated for removal in Python 3.15" - ) - ): + depr_msg = ( + "'typing.no_type_check_decorator' is deprecated " + "and slated for removal in Python 3.15" + ) + with self.assertWarnsRegex(DeprecationWarning, depr_msg): @no_type_check_decorator def magic_decorator(func): return func From 44ec437128f3eb471ed8db82d1b8fd471c72c6ec Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Sun, 2 Jul 2023 23:46:32 +0100 Subject: [PATCH 3/3] ASCII-art Sphinx tables --- Doc/library/typing.rst | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index b168e4467a4321..114515158f8338 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -3631,18 +3631,20 @@ Certain features in ``typing`` are deprecated and may be removed in a future version of Python. The following table summarizes major deprecations for your convenience. This is subject to change, and not all deprecations are listed. -+----------------------------------+---------------+-------------------+----------------+ -| Feature | Deprecated in | Projected removal | PEP/issue | -+==================================+===============+===================+================+ -| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` | -| collections | | | | -+----------------------------------+---------------+-------------------+----------------+ -| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` | -+----------------------------------+---------------+-------------------+----------------+ -| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` | -+----------------------------------+---------------+-------------------+----------------+ -| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` | -| ``typing.Sized`` | | | | -+----------------------------------+---------------+-------------------+----------------+ -| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` | -+----------------------------------+---------------+-------------------+----------------+ ++-------------------------------------+---------------+-------------------+----------------+ +| Feature | Deprecated in | Projected removal | PEP/issue | ++=====================================+===============+===================+================+ +| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` | +| collections | | | | ++-------------------------------------+---------------+-------------------+----------------+ +| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` | ++-------------------------------------+---------------+-------------------+----------------+ +| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` | ++-------------------------------------+---------------+-------------------+----------------+ +| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` | +| ``typing.Sized`` | | | | ++-------------------------------------+---------------+-------------------+----------------+ +| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` | ++-------------------------------------+---------------+-------------------+----------------+ +| ``typing.no_type_check_decorator`` | 3.13 | 3.15 | :gh:`106309` | ++-------------------------------------+---------------+-------------------+----------------+ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy