-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
Needs PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)
Description
Bug description
This looks like perfectly valid Python to me, but not to pylint:
"""pylint minimal example."""
import re
from dataclasses import dataclass
@dataclass
class _Test:
pattern_instance: re.Pattern[str]
C = _Test(pattern_instance=re.compile(r'regex pattern'))
print(C.pattern_instance.pattern) # E1101: Instance of 'Pattern' has no 'pattern' member (no-member)
If I don't go through a dataclass with the variable, it seems pylint is smart enough to know what's going on. But not when it's set up like this.
Configuration
No response
Command used
pylint pylint_pattern.py
Pylint output
************* Module pylint_pattern
pylint_pattern.py:10:6: E1101: Instance of 'Pattern' has no 'pattern' member (no-member)
------------------------------------------------------------------
Your code has been rated at 1.67/10 (previous run: 1.67/10, +0.00)
Expected behavior
-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 1.67/10, +8.33)
I get this if I add # pylint: disable=no-member
to the last line, but this shouldn't be necessary.
Pylint version
pylint 2.14.5
astroid 2.11.7
Python 3.10.5 (main, Jun 15 2022, 13:20:57) [GCC 9.4.0]
OS / Environment
Windows 11, WSL (Ubuntu)
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
Needs PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationNeeds astroid Brain 🧠Needs a brain tip in astroid (then an astroid upgrade)Needs a brain tip in astroid (then an astroid upgrade)