Skip to content

Commit

Permalink
SONARPY-2345 Document new S1172 FN when super class is ambiguous
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-serre-sonarsource committed Nov 18, 2024
1 parent e0a6c3c commit a53a73b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ void test() {
@Test
void test_import() {
PythonCheckVerifier.verify(
List.of("src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImport.py","src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImported.py"),
List.of(
"src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImport.py",
"src/test/resources/checks/unusedFunctionParameter/unusedFunctionParameterImported.py"
),
new UnusedFunctionParameterCheck()
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unusedFunctionParameterImported import ImportedParent
from unusedFunctionParameterImported import ImportedParent, ParentWithDuplicatedParent

class ChildFromImported(ImportedParent):

# SONARPY-2327 `method_defined_in_child_class_only` is not considered a member of ImportedParent class, thus S1172 is raised
Expand All @@ -9,3 +10,9 @@ def method_defined_in_child_class_only(self, a): # Noncompliant
def method_defined_in_child_class_only_and_not_used(self, a): # Noncompliant
# ^
return compute()

class ChildFromDuplicated(ParentWithDuplicatedParent):

def do_something(self, a): # FN ChildFromDuplicated has an unresolved type hierarchy, because of the duplicated parent classes
return compute()

Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
class ImportedParent:
def using_child_method(self):
return self.method_defined_in_child_class_only(1,2)

class DuplicatedParent:
...

class DuplicatedParent:
...

class ParentWithDuplicatedParent(DuplicatedParent):
...

0 comments on commit a53a73b

Please sign in to comment.