diff --git a/tests/functional/n/no/no_member_type_introspection.py b/tests/functional/n/no/no_member_type_introspection.py new file mode 100644 index 00000000000..9e720b422c6 --- /dev/null +++ b/tests/functional/n/no/no_member_type_introspection.py @@ -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] diff --git a/tests/functional/n/no/no_member_type_introspection.txt b/tests/functional/n/no/no_member_type_introspection.txt new file mode 100644 index 00000000000..828361c5c97 --- /dev/null +++ b/tests/functional/n/no/no_member_type_introspection.txt @@ -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 \ No newline at end of file diff --git a/tests/functional/n/no/no_member_type_introspection_base.py b/tests/functional/n/no/no_member_type_introspection_base.py new file mode 100644 index 00000000000..33d61341de1 --- /dev/null +++ b/tests/functional/n/no/no_member_type_introspection_base.py @@ -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)()