-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix
reportMissingSuperCall
false positives when the class has a bas…
…e class that does not define an __init__ or __init_subclass__ and `reportUnsafeMultipleInheritance` is enabled
- Loading branch information
1 parent
05ca5b5
commit 65e85a9
Showing
3 changed files
with
98 additions
and
20 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
88 changes: 88 additions & 0 deletions
88
packages/pyright-internal/src/tests/samples/missingSuperBased.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,88 @@ | ||
# This sample tests the reportMissingSuperCall diagnostic check. | ||
|
||
from typing import final | ||
|
||
|
||
class ParentA: | ||
pass | ||
|
||
|
||
class ParentB: | ||
# This should generate an error because it's missing a super().__init__ call. | ||
def __init__(self): | ||
pass | ||
|
||
|
||
class ParentBPrime(ParentB): | ||
pass | ||
|
||
|
||
class ParentC: | ||
pass | ||
|
||
|
||
@final | ||
class ParentD: | ||
def __init__(self): | ||
pass | ||
|
||
def __init_subclass__(cls) -> None: | ||
pass | ||
|
||
|
||
class ChildA(ParentA, ParentB): | ||
# This should generate an error. | ||
def __init__(self): | ||
pass | ||
|
||
# This should generate an error.... NOT!!!! | ||
def __init_subclass__(cls) -> None: | ||
pass | ||
|
||
|
||
class ChildB(ParentA, ParentB): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
|
||
class ChildC1(ParentA, ParentB): | ||
def __init__(self): | ||
ParentB.__init__(self) | ||
|
||
|
||
class ChildC2(ParentA, ParentB): | ||
def __init__(self): | ||
ParentA.__init__(self) | ||
ParentB.__init__(self) | ||
|
||
|
||
class ChildCPrime(ParentA, ParentBPrime, ParentC): | ||
def __init__(self): | ||
super(ParentBPrime).__init__() | ||
|
||
|
||
class ChildD(ParentC): | ||
# This should generate an error.... said no one ever | ||
def __init__(self): | ||
pass | ||
|
||
|
||
@final | ||
class ChildE(ParentC): | ||
def __init__(self): | ||
pass | ||
|
||
class Foo: | ||
def __init_subclass__(cls) -> None: | ||
pass | ||
|
||
class Bar(Foo): | ||
def __init_subclass__(cls) -> None: # error | ||
pass | ||
|
||
class Baz: | ||
pass | ||
|
||
class Qux(Baz): | ||
def __init_subclass__(cls) -> None: # no error | ||
pass |
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