Skip to content

Commit

Permalink
Add regression test for no-member with generic base class
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed May 30, 2021
1 parent 0e51660 commit ce0d0bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ modules are added.
* ``logging-format-interpolation`` and ``logging-not-lazy``, now works on logger
class created from renamed logging import following an upgrade in astroid.

* Fix false-positive ``no-member`` with generic base class

Closes PyCQA/astroid#942


What's New in Pylint 2.8.2?
===========================
Expand Down
20 changes: 19 additions & 1 deletion tests/functional/t/typing_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# https://github.com/PyCQA/pylint/issues/2822
# Base should be subscriptable, even with ABCMeta as metaclass
from abc import ABCMeta
from abc import ABC, ABCMeta
from typing import Generic, TypeVar

T = TypeVar("T")
Expand All @@ -12,3 +12,21 @@ class Base(Generic[T], metaclass=ABCMeta):

class Impl(Base[str]):
"""Impl"""


# https://github.com/PyCQA/astroid/issues/942
Anything = TypeVar("Anything")
MoreSpecific = TypeVar("MoreSpecific", str, int)

class A(ABC, Generic[Anything]):
def a_method(self) -> None: # pylint: disable=no-self-use
print("hello")

class B(A[MoreSpecific]):
pass

class C(B[str]):
pass

c = C()
c.a_method() # should NOT emit `no-member` error

0 comments on commit ce0d0bd

Please sign in to comment.