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 29, 2022
1 parent 530d790 commit ce2a9f9
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
51 changes: 51 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,51 @@
"""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

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:26:0:26:15::Instance of 'ExtBaseA' has no 'only_in_b' member; maybe 'only_in_a'?:INFERENCE
no-member:46:0:46:15::Instance of 'Base' has no 'only_in_a' member:INFERENCE
no-member:51:0:51: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 ce2a9f9

Please sign in to comment.