Skip to content

Commit

Permalink
SONARPY-2345 Document new S1172 FN when super class is ambiguous (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-serre-sonarsource authored Nov 19, 2024
1 parent 9c6e537 commit 1df1fc5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 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,11 +1,18 @@
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
# SONARPY-1829 `method_defined_in_child_class_only` is not considered a member of ImportedParent class, thus S1172 is raised
def method_defined_in_child_class_only(self, a): # Noncompliant
# ^
return compute()

def method_defined_in_child_class_only_and_not_used(self, a): # Noncompliant
# ^
return compute()

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()

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 1df1fc5

Please sign in to comment.