-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#5697) Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
- Loading branch information
1 parent
7611ec4
commit 6977e48
Showing
15 changed files
with
128 additions
and
17 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
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
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
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
super-init-not-called:25:4:26:27:ZZZZ.__init__:__init__ method from base class 'BBBB' is not called:UNDEFINED | ||
super-init-not-called:58:4:59:20:AssignedInit.__init__:__init__ method from base class 'NewStyleC' is not called:UNDEFINED | ||
super-init-not-called:25:4:26:27:ZZZZ.__init__:__init__ method from base class 'BBBB' is not called:INFERENCE | ||
super-init-not-called:58:4:59:20:AssignedInit.__init__:__init__ method from base class 'NewStyleC' is not called:INFERENCE |
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
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 |
---|---|---|
@@ -1,13 +1,22 @@ | ||
"""This should not emit a super-init-not-called warning. It previously did this, because | ||
``next(node.infer())`` was used in that checker's logic and the first inferred node | ||
was an Uninferable object, leading to this false positive.""" | ||
"""Tests for super-init-not-called.""" | ||
# pylint: disable=too-few-public-methods | ||
|
||
import ctypes | ||
|
||
|
||
class Foo(ctypes.BigEndianStructure): | ||
"""A class""" | ||
"""This class should not emit a super-init-not-called warning. | ||
It previously did, because ``next(node.infer())`` was used in that checker's logic | ||
and the first inferred node was an Uninferable object, leading to this false positive. | ||
""" | ||
|
||
def __init__(self): | ||
ctypes.BigEndianStructure.__init__(self) | ||
|
||
|
||
class UninferableChild(UninferableParent): # [undefined-variable] | ||
"""An implementation that test if we don't crash on uninferable parents.""" | ||
|
||
def __init__(self): | ||
... |
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 @@ | ||
undefined-variable:18:23:18:40:UninferableChild:Undefined variable 'UninferableParent':UNDEFINED |
22 changes: 22 additions & 0 deletions
22
tests/functional/s/super/super_init_not_called_extensions.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,22 @@ | ||
"""Tests for super-init-not-called.""" | ||
# pylint: disable=too-few-public-methods | ||
|
||
from typing_extensions import Protocol as ExtensionProtocol | ||
|
||
|
||
class TestProto(ExtensionProtocol): | ||
"""A protocol without __init__ using Protocol from typing_extensions.""" | ||
|
||
|
||
class TestParent(TestProto): | ||
"""An implementation.""" | ||
|
||
def __init__(self): | ||
... | ||
|
||
|
||
class TestChild(TestParent): | ||
"""An implementation which should call the init of TestParent.""" | ||
|
||
def __init__(self): # [super-init-not-called] | ||
... |
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,2 @@ | ||
[testoptions] | ||
max_pyver=3.9 |
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 @@ | ||
super-init-not-called:21:4:22:11:TestChild.__init__:__init__ method from base class 'TestParent' is not called:INFERENCE |
22 changes: 22 additions & 0 deletions
22
tests/functional/s/super/super_init_not_called_extensions_py310.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,22 @@ | ||
"""Tests for super-init-not-called.""" | ||
# pylint: disable=too-few-public-methods | ||
|
||
from typing_extensions import Protocol as ExtensionProtocol | ||
|
||
|
||
class TestProto(ExtensionProtocol): | ||
"""A protocol without __init__ using Protocol from typing_extensions.""" | ||
|
||
|
||
class TestParent(TestProto): | ||
"""An implementation.""" | ||
|
||
def __init__(self): | ||
... | ||
|
||
|
||
class TestChild(TestParent): | ||
"""An implementation which should call the init of TestParent.""" | ||
|
||
def __init__(self): # [super-init-not-called] | ||
... |
4 changes: 4 additions & 0 deletions
4
tests/functional/s/super/super_init_not_called_extensions_py310.rc
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,4 @@ | ||
[testoptions] | ||
# Windows test environments on >= 3.10 don't have typing_extensions | ||
exclude_platforms=win32 | ||
min_pyver=3.10 |
1 change: 1 addition & 0 deletions
1
tests/functional/s/super/super_init_not_called_extensions_py310.txt
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 @@ | ||
super-init-not-called:21:4:22:11:TestChild.__init__:__init__ method from base class 'TestParent' is not called:INFERENCE |
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,20 @@ | ||
"""Tests for super-init-not-called with Protocol.""" | ||
# pylint: disable=too-few-public-methods | ||
|
||
from abc import abstractmethod | ||
from typing import Protocol | ||
|
||
|
||
class MyProtocol(Protocol): | ||
"""A protocol.""" | ||
|
||
@abstractmethod | ||
def __init__(self) -> None: | ||
raise NotImplementedError | ||
|
||
|
||
class ProtocolImplimentation(MyProtocol): | ||
"""An implementation.""" | ||
|
||
def __init__(self) -> None: | ||
... |
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.8 |