]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106309: Deprecate typing.no_type_check_decorator (#106312)
authorAlex Waygood <Alex.Waygood@Gmail.com>
Thu, 13 Jul 2023 13:30:35 +0000 (14:30 +0100)
committerGitHub <noreply@github.com>
Thu, 13 Jul 2023 13:30:35 +0000 (14:30 +0100)
Doc/library/typing.rst
Doc/whatsnew/3.13.rst
Lib/test/test_typing.py
Lib/typing.py
Misc/NEWS.d/next/Library/2023-07-01-16-51-55.gh-issue-106309.hSlB17.rst [new file with mode: 0644]

index 11af3ea3c9030abc6f8242704016fb6225d76c6b..0cf875582f7f427a7ba8d71e3ff03c958c6b2334 100644 (file)
@@ -2849,6 +2849,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
 
@@ -3648,18 +3651,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`   |
++-------------------------------------+---------------+-------------------+----------------+
index b7c436fc15161165639d64c7b37e6832fa25e868..06fcaf4608cdcb54328fbaea27c5c0cb37f28c3c 100644 (file)
@@ -161,6 +161,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
index 1df21926d1f67ece10a1d28d0264bc68513e7653..0450a87577eceab6b28272edddf350a2e0df4115 100644 (file)
@@ -5794,10 +5794,14 @@ class ForwardRefTests(BaseTestCase):
                 get_type_hints(clazz)
 
     def test_meta_no_type_check(self):
-
-        @no_type_check_decorator
-        def magic_decorator(func):
-            return func
+        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
 
         self.assertEqual(magic_decorator.__name__, 'magic_decorator')
 
index 9187b74b0e2e1fc53a4eb514f83876c90e7b1ac1..387b4c5ad5284b74591e35e8b185c9864814d7f7 100644 (file)
@@ -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 (file)
index 0000000..5bd3880
--- /dev/null
@@ -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.