From fa3a5ee392c78640018c430337a53f50cca184fb Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Sun, 8 Sep 2024 18:50:21 +0300 Subject: [PATCH 1/5] Fixed annotation for typeguard_ignore() to match one for typing.no_type_check() --- src/typeguard/_decorators.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/typeguard/_decorators.py b/src/typeguard/_decorators.py index cf32533..af6f82b 100644 --- a/src/typeguard/_decorators.py +++ b/src/typeguard/_decorators.py @@ -16,20 +16,18 @@ from ._transformer import TypeguardTransformer from ._utils import Unset, function_name, get_stacklevel, is_method_of, unset +T_CallableOrType = TypeVar("T_CallableOrType", bound=Callable[..., Any]) + if TYPE_CHECKING: from typeshed.stdlib.types import _Cell - _F = TypeVar("_F") - - def typeguard_ignore(f: _F) -> _F: + def typeguard_ignore(f: T_CallableOrType) -> T_CallableOrType: """This decorator is a noop during static type-checking.""" return f else: from typing import no_type_check as typeguard_ignore # noqa: F401 -T_CallableOrType = TypeVar("T_CallableOrType", bound=Callable[..., Any]) - def make_cell(value: object) -> _Cell: return (lambda: value).__closure__[0] # type: ignore[index] From 07dfad77a54760ed5b6b7eebb2e19090235b5e53 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Tue, 29 Oct 2024 15:34:56 +0300 Subject: [PATCH 2/5] Further improving typeguard_ignore() signature to be compatible with typing.no_type_check() --- src/typeguard/_decorators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/typeguard/_decorators.py b/src/typeguard/_decorators.py index af6f82b..1d171ec 100644 --- a/src/typeguard/_decorators.py +++ b/src/typeguard/_decorators.py @@ -21,9 +21,9 @@ if TYPE_CHECKING: from typeshed.stdlib.types import _Cell - def typeguard_ignore(f: T_CallableOrType) -> T_CallableOrType: + def typeguard_ignore(arg: T_CallableOrType) -> T_CallableOrType: """This decorator is a noop during static type-checking.""" - return f + return arg else: from typing import no_type_check as typeguard_ignore # noqa: F401 From ba5c75d140587c5a8252ec5816bdd09043307069 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Tue, 29 Oct 2024 17:00:01 +0300 Subject: [PATCH 3/5] Added changelog line --- docs/versionhistory.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 7ab922c..0804ff3 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -4,6 +4,10 @@ Version history This library adheres to `Semantic Versioning 2.0 `_. +- Made sure that `typeguard_ignore()` signature is fully compatible + with `typing.no_type_check()` + (`#497 `_; PR by @jolaf) + **4.4.0** (2024-10-27) - Added proper checking for method signatures in protocol checks From 51f0120fdfec01e2352a53ef99835fd95fbe995f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Tue, 29 Oct 2024 16:03:06 +0200 Subject: [PATCH 4/5] Update docs/versionhistory.rst --- docs/versionhistory.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 0804ff3..d57de73 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -4,9 +4,8 @@ Version history This library adheres to `Semantic Versioning 2.0 `_. -- Made sure that `typeguard_ignore()` signature is fully compatible - with `typing.no_type_check()` - (`#497 `_; PR by @jolaf) +- Changed the signature of ``typeguard_ignore()`` to be compatible with + `typing.no_type_check()` (PR by @jolaf) **4.4.0** (2024-10-27) From 1affe2d8fa0bfe2ccdc2256f3e29e75cee8c7129 Mon Sep 17 00:00:00 2001 From: Vasily Zakharov Date: Tue, 29 Oct 2024 17:20:39 +0300 Subject: [PATCH 5/5] Changelog fix --- docs/versionhistory.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index d57de73..cb1563c 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -5,7 +5,7 @@ This library adheres to `Semantic Versioning 2.0 `_. - Changed the signature of ``typeguard_ignore()`` to be compatible with - `typing.no_type_check()` (PR by @jolaf) + ``typing.no_type_check()`` (PR by @jolaf) **4.4.0** (2024-10-27)