-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONARPY-2330 Add unit test case on S6542 when a class is inherited fr…
…om an imported class with a metaclass
- Loading branch information
1 parent
4da8b75
commit d69535d
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
python-checks/src/test/resources/checks/useOfAnyAsTypeHintImported.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from abc import ABCMeta | ||
|
||
class ImportedParentWithMetaClass(metaclass=ABCMeta): ... |
15 changes: 15 additions & 0 deletions
15
python-checks/src/test/resources/checks/useOfAnyAsTypeHintImporting.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Any | ||
from abc import ABCMeta | ||
from useOfAnyAsTypeHintImported import ImportedParentWithMetaClass | ||
|
||
class LocalParent: ... | ||
|
||
class LocalParentWithMetaClass(metaclass=ABCMeta): ... | ||
|
||
class LocalWithMetaClassInherited(LocalParentWithMetaClass): | ||
def local_inherited_foo(self) -> Any: # Noncompliant | ||
... | ||
|
||
class ImportedWithMetaClassInherited(ImportedParentWithMetaClass): | ||
def imported_inherited_foo(self) -> Any: # FN SONARPY-2331 | ||
... |