Skip to content

Commit

Permalink
Add functional test demonstrating issue with type introspection
Browse files Browse the repository at this point in the history
  • Loading branch information
kriek committed Sep 30, 2022
1 parent 530d790 commit 811d2c1
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/functional/n/no/no_member_type_introspection.py
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]
3 changes: 3 additions & 0 deletions tests/functional/n/no/no_member_type_introspection.txt
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 tests/functional/n/no/no_member_type_introspection_base.py
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)()

0 comments on commit 811d2c1

Please sign in to comment.