Skip to content

Commit

Permalink
SONARPY-2362 Document no issue on S6542 when inheriting from annotate…
Browse files Browse the repository at this point in the history
…d class member (#2174)
  • Loading branch information
guillaume-dequenne-sonarsource authored Nov 26, 2024
1 parent 4e4d5b9 commit 7119dc6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@ def return_type_check(self, text) -> Any: # Compliant
@my_annotation[42]
def some_annotated_method(self, text: Any): # Noncompliant
...

from typing import Callable
class LocalClassWithAnnotatedMember:
my_member: Callable[[Any],Any] # No issue on nested values of "Callable"

class LocalClassChild(LocalClassWithAnnotatedMember):
def my_member(self, param: Any) -> Any: # OK, defined in parent
...
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
@@ -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): ...

Expand All @@ -14,3 +14,7 @@ def imported_inherited_foo(self) -> Any: # Noncompliant
class ImportedWithMetaClassInherited(ImportedParentWithMetaClass):
def imported_inherited_foo(self) -> Any: # Noncompliant
...

class MyChild(MyClassWithAnnotatedMember):
def my_member(self, param: Any) -> Any: # OK, defined in parent
...

0 comments on commit 7119dc6

Please sign in to comment.