From 1cd71cdcfe443c830a6bdd06ec38f2ad863c1d18 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 31 Jan 2024 21:10:25 -0800 Subject: [PATCH 1/2] Draft modification to the `@no_type_check` section of the spec. --- docs/spec/directives.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/spec/directives.rst b/docs/spec/directives.rst index 57f3c4b6e..942ca78a8 100644 --- a/docs/spec/directives.rst +++ b/docs/spec/directives.rst @@ -108,10 +108,17 @@ This approach may also be useful to handle import cycles. ``@no_type_check`` ------------------ -To mark portions of the program that should not be covered by type -hinting, you can use the ``@typing.no_type_check`` decorator on a class or function. -Functions with this decorator should be treated as having -no annotations. +The ``@typing.no_type_check`` decorator may be supported by type checkers +for functions and classes. + +If a type checker supports the ``no_type_check`` decorator for functions, it +should suppress all type errors for the ``def`` statement and its body including +any nested functions or classes. It should also ignore all parameter +and return type annotations and treat the function as if it were unannotated. + +If a type checker supports the ``no_type_check`` decorator for classes, it +should suppress all type errors for the ``class`` statement and its body +including any nested functions or classes. Version and platform checking ----------------------------- From 73aa420330b8a5293d65e97e5004fdbb6a2ff650 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Thu, 1 Feb 2024 22:48:35 -0800 Subject: [PATCH 2/2] Updated wording to indicate that the behavior of `@no_type_check` when applied to a class is undefined at this time. --- docs/spec/directives.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/spec/directives.rst b/docs/spec/directives.rst index 942ca78a8..3f8268c23 100644 --- a/docs/spec/directives.rst +++ b/docs/spec/directives.rst @@ -116,9 +116,8 @@ should suppress all type errors for the ``def`` statement and its body including any nested functions or classes. It should also ignore all parameter and return type annotations and treat the function as if it were unannotated. -If a type checker supports the ``no_type_check`` decorator for classes, it -should suppress all type errors for the ``class`` statement and its body -including any nested functions or classes. +The behavior for the ``no_type_check`` decorator when applied to a class is +left undefined by the typing spec at this time. Version and platform checking -----------------------------