Skip to content

Commit ce0d0bd

Browse files
committed
Add regression test for no-member with generic base class
1 parent 0e51660 commit ce0d0bd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ modules are added.
115115
* ``logging-format-interpolation`` and ``logging-not-lazy``, now works on logger
116116
class created from renamed logging import following an upgrade in astroid.
117117

118+
* Fix false-positive ``no-member`` with generic base class
119+
120+
Closes PyCQA/astroid#942
121+
118122

119123
What's New in Pylint 2.8.2?
120124
===========================

tests/functional/t/typing_generic.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

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

1313
class Impl(Base[str]):
1414
"""Impl"""
15+
16+
17+
# https://github.com/PyCQA/astroid/issues/942
18+
Anything = TypeVar("Anything")
19+
MoreSpecific = TypeVar("MoreSpecific", str, int)
20+
21+
class A(ABC, Generic[Anything]):
22+
def a_method(self) -> None: # pylint: disable=no-self-use
23+
print("hello")
24+
25+
class B(A[MoreSpecific]):
26+
pass
27+
28+
class C(B[str]):
29+
pass
30+
31+
c = C()
32+
c.a_method() # should NOT emit `no-member` error

0 commit comments

Comments
 (0)