-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test demonstrating issue with type introspection
- Loading branch information
Showing
3 changed files
with
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"""Tests for no-member when type(self)() is returned by a method.""" | ||
# pylint: disable=fixme,missing-class-docstring,missing-function-docstring,too-few-public-methods | ||
|
||
# Test for: https://github.com/PyCQA/pylint/issues/7464 | ||
# TODO: the findings are false positives, see above link to issue. | ||
|
||
from . import no_member_type_introspection_base as ext | ||
|
||
|
||
class ExtBaseA(ext.Base): | ||
def only_in_a(self): | ||
pass | ||
|
||
|
||
class ExtBaseB(ext.Base): | ||
def only_in_b(self): | ||
pass | ||
|
||
|
||
a = ExtBaseA() | ||
new_a = a.return_type() | ||
new_a.only_in_a() | ||
|
||
|
||
b = ExtBaseB() | ||
new_b = b.return_type() | ||
new_b.only_in_b() # [no-member] | ||
|
||
|
||
class Base: | ||
def return_type(self): | ||
return type(self)() | ||
|
||
|
||
class LocalBaseA(Base): | ||
def only_in_a(self): | ||
pass | ||
|
||
|
||
class LocalBaseB(Base): | ||
def only_in_b(self): | ||
pass | ||
|
||
|
||
a = LocalBaseA() | ||
new_a = a.return_type() | ||
new_a.only_in_a() # [no-member] | ||
|
||
|
||
b = LocalBaseB() | ||
new_b = b.return_type() | ||
new_b.only_in_b() # [no-member] |
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 @@ | ||
no-member:27:0:27:15::Instance of 'ExtBaseA' has no 'only_in_b' member; maybe 'only_in_a'?:INFERENCE | ||
no-member:47:0:47:15::Instance of 'Base' has no 'only_in_a' member:INFERENCE | ||
no-member:52:0:52:15::Instance of 'Base' has no 'only_in_b' member:INFERENCE |
10 changes: 10 additions & 0 deletions
10
tests/functional/n/no/no_member_type_introspection_base.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,10 @@ | ||
"""Tests for no-member when type(self)() is returned by a method.""" | ||
# pylint: disable=missing-class-docstring,missing-function-docstring,too-few-public-methods | ||
|
||
|
||
# Test for: https://github.com/PyCQA/pylint/issues/7464 | ||
|
||
|
||
class Base: | ||
def return_type(self): | ||
return type(self)() |