From 4fd77107e4ca2909a022ed5368ce1b2d89c83667 Mon Sep 17 00:00:00 2001 From: Guillaume Dequenne Date: Fri, 22 Nov 2024 09:38:56 +0100 Subject: [PATCH] Document no issue on S6542 when inheriting from annotated class member --- .../useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImported.py | 4 ++++ .../useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImporting.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImported.py b/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImported.py index d7054a2333..d2d8ef7176 100644 --- a/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImported.py +++ b/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImported.py @@ -3,3 +3,7 @@ class ImportedParentWithoutMetaClass: ... class ImportedParentWithMetaClass(metaclass=ABCMeta): ... + +from typing import Callable +class MyClassWithAnnotatedMember: + my_member: Callable[[Any],Any] # No issue on nested values of "Callable" diff --git a/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImporting.py b/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImporting.py index 597b555f7a..a26a3ef4f8 100644 --- a/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImporting.py +++ b/python-checks/src/test/resources/checks/useOfAnyAsTypeHintCheck/useOfAnyAsTypeHintImporting.py @@ -1,6 +1,6 @@ from typing import Any from abc import ABCMeta -from useOfAnyAsTypeHintImported import ImportedParentWithoutMetaClass, ImportedParentWithMetaClass +from useOfAnyAsTypeHintImported import ImportedParentWithoutMetaClass, ImportedParentWithMetaClass, MyClassWithAnnotatedMember class LocalParentWithMetaClass(metaclass=ABCMeta): ... @@ -14,3 +14,7 @@ def imported_inherited_foo(self) -> Any: # Noncompliant class ImportedWithMetaClassInherited(ImportedParentWithMetaClass): def imported_inherited_foo(self) -> Any: # Noncompliant ... + +class MyChild(MyClass): + def my_member(self, param: Any) -> Any: # OK, defined in parent + ...