If I want to alias/wrap a field for a dataclass, then pylint thinks that the members of the dataclass at that point are actually Field objects (at least when checking for no-member). Here's a minimal example:
from dataclasses import dataclass, field
def field_alias(**kwargs):
# do some stuff analyzing the args
# The following ignore is "fine" because it only needs to happen in one spot
return field(**kwargs) # pylint: disable=invalid-field-call
class ObjectWSubField:
sub_field: int
@dataclass(frozen=True)
class Temp:
the_object: ObjectWSubField = field_alias(type=ObjectWSubField)
def some_method(self):
# no-member error thrown here and I don't want to throw in an ignore at every spot
print(self.the_object.sub_field)
Configuration
No response
Command used
pylint a.py
Pylint output
a.py:15:14: E1101: Instance of 'Field' has no 'sub_field' member (no-member)
Expected behavior
No error throw because object is correctly identified as the type it is hinted as
Pylint version
pylint 3.2.6
astroid 3.2.4
Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]
Bug description
If I want to alias/wrap a field for a dataclass, then pylint thinks that the members of the dataclass at that point are actually
Field
objects (at least when checking forno-member
). Here's a minimal example:Configuration
No response
Command used
Pylint output
Expected behavior
No error throw because object is correctly identified as the type it is hinted as
Pylint version
OS / Environment
Windows 11
Additional dependencies
No response