Skip to content

Commit

Permalink
SONARPY-2363 Document no issue on S1172 when inheriting from annotate…
Browse files Browse the repository at this point in the history
…d class member (#2175)
  • Loading branch information
guillaume-dequenne-sonarsource authored Nov 26, 2024
1 parent 7119dc6 commit a7ce426
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 @@ -201,3 +201,12 @@ class FakeMetaclass(type):
class ClassWithFakeMetaClass(metaclass=FakeMetaclass):
def execute(self, name):
print("Execute")


from typing import Callable
class LocalClassWithAnnotatedMember:
my_member: Callable[[str, int],str]

class LocalClassChild(LocalClassWithAnnotatedMember):
def my_member(self, param, other_param): # OK, respecting contract defined in parent
print("Execute")
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from unusedFunctionParameterImported import ImportedParent, ParentWithDuplicatedParent
from unusedFunctionParameterImported import ImportedParent, ParentWithDuplicatedParent, MyClassWithAnnotatedMember

class ChildFromImported(ImportedParent):

Expand All @@ -16,3 +16,6 @@ class ChildFromDuplicated(ParentWithDuplicatedParent):
def do_something(self, a): # FN SONARPY-1829 ChildFromDuplicated has an unresolved type hierarchy, because of the duplicated parent classes
return compute()

class MyChild(MyClassWithAnnotatedMember):
def my_member(self, param, other_param): # OK, respecting contract defined in parent
return compute()
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ class DuplicatedParent:

class ParentWithDuplicatedParent(DuplicatedParent):
...

from typing import Callable
class MyClassWithAnnotatedMember:
my_member: Callable[[str, int],str]

0 comments on commit a7ce426

Please sign in to comment.