Skip to content

Commit 32718f9

Browse files
authored
gh-106309: Deprecate typing.no_type_check_decorator (#106312)
1 parent 4b4a5b7 commit 32718f9

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

Doc/library/typing.rst

+20-15
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,9 @@ Functions and decorators
28492849
This wraps the decorator with something that wraps the decorated
28502850
function in :func:`no_type_check`.
28512851

2852+
.. deprecated-removed:: 3.13 3.15
2853+
No type checker ever added support for ``@no_type_check_decorator``. It
2854+
is therefore deprecated, and will be removed in Python 3.15.
28522855

28532856
.. decorator:: override
28542857

@@ -3648,18 +3651,20 @@ Certain features in ``typing`` are deprecated and may be removed in a future
36483651
version of Python. The following table summarizes major deprecations for your
36493652
convenience. This is subject to change, and not all deprecations are listed.
36503653

3651-
+----------------------------------+---------------+-------------------+----------------+
3652-
| Feature | Deprecated in | Projected removal | PEP/issue |
3653-
+==================================+===============+===================+================+
3654-
| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` |
3655-
| collections | | | |
3656-
+----------------------------------+---------------+-------------------+----------------+
3657-
| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` |
3658-
+----------------------------------+---------------+-------------------+----------------+
3659-
| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` |
3660-
+----------------------------------+---------------+-------------------+----------------+
3661-
| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` |
3662-
| ``typing.Sized`` | | | |
3663-
+----------------------------------+---------------+-------------------+----------------+
3664-
| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` |
3665-
+----------------------------------+---------------+-------------------+----------------+
3654+
+-------------------------------------+---------------+-------------------+----------------+
3655+
| Feature | Deprecated in | Projected removal | PEP/issue |
3656+
+=====================================+===============+===================+================+
3657+
| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` |
3658+
| collections | | | |
3659+
+-------------------------------------+---------------+-------------------+----------------+
3660+
| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` |
3661+
+-------------------------------------+---------------+-------------------+----------------+
3662+
| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` |
3663+
+-------------------------------------+---------------+-------------------+----------------+
3664+
| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` |
3665+
| ``typing.Sized`` | | | |
3666+
+-------------------------------------+---------------+-------------------+----------------+
3667+
| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` |
3668+
+-------------------------------------+---------------+-------------------+----------------+
3669+
| ``typing.no_type_check_decorator`` | 3.13 | 3.15 | :gh:`106309` |
3670+
+-------------------------------------+---------------+-------------------+----------------+

Doc/whatsnew/3.13.rst

+4
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ Deprecated
161161
``NT = NamedTuple("NT", [])``. To create a TypedDict class with 0 fields, use
162162
``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.
163163
(Contributed by Alex Waygood in :gh:`105566` and :gh:`105570`.)
164+
* :func:`typing.no_type_check_decorator` is deprecated, and scheduled for
165+
removal in Python 3.15. After eight years in the :mod:`typing` module, it
166+
has yet to be supported by any major type checkers.
167+
(Contributed by Alex Waygood in :gh:`106309`.)
164168

165169
* :mod:`array`'s ``'u'`` format code, deprecated in docs since Python 3.3,
166170
emits :exc:`DeprecationWarning` since 3.13

Lib/test/test_typing.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -5794,10 +5794,14 @@ class F:
57945794
get_type_hints(clazz)
57955795

57965796
def test_meta_no_type_check(self):
5797-
5798-
@no_type_check_decorator
5799-
def magic_decorator(func):
5800-
return func
5797+
depr_msg = (
5798+
"'typing.no_type_check_decorator' is deprecated "
5799+
"and slated for removal in Python 3.15"
5800+
)
5801+
with self.assertWarnsRegex(DeprecationWarning, depr_msg):
5802+
@no_type_check_decorator
5803+
def magic_decorator(func):
5804+
return func
58015805

58025806
self.assertEqual(magic_decorator.__name__, 'magic_decorator')
58035807

Lib/typing.py

+2
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,8 @@ def no_type_check_decorator(decorator):
23952395
This wraps the decorator with something that wraps the decorated
23962396
function in @no_type_check.
23972397
"""
2398+
import warnings
2399+
warnings._deprecated("typing.no_type_check_decorator", remove=(3, 15))
23982400
@functools.wraps(decorator)
23992401
def wrapped_decorator(*args, **kwds):
24002402
func = decorator(*args, **kwds)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate :func:`typing.no_type_check_decorator`. No major type checker ever
2+
added support for this decorator. Patch by Alex Waygood.

0 commit comments

Comments
 (0)