no-member / E1101ΒΆ
Message emitted:
%s %r has no %r member%s
Description:
Used when a variable is accessed for a nonexistent member.
Problematic code:
fruit.py:
class Apple:
flavor = "sweet"
class Cucumber:
color = "green"
print(Cucumber().flavor) # [no-member]
path.py:
from pathlib import Path
directories = Path(".").mothers # [no-member]
Correct code:
fruit.py:
class Apple:
flavor = "sweet"
class Cucumber:
color = "green"
print(Apple().flavor)
print(Cucumber().color)
path.py:
from pathlib import Path
directories = Path(".").parents
Additional details:
A no-member error means one of:
pylint found a bug in your code
the dependencies are not installed in pylint's environment
the attribute lives in a C extension module, and pylint is refraining from importing it
the attribute is generated dynamically
The only way to get an AST out of a C extension is to load it into the active Python interpreter, which may run arbitrary code, so pylint does not do it by default. If you accept that, tell it to load the module and build the AST from it, one package at a time with extension-pkg-allow-list or for every extension with unsafe-load-any-extension:
$ pylint --extension-pkg-allow-list=your_c_extension
$ pylint --unsafe-load-any-extension=y
Attributes missing from a C extension are reported as c-extension-no-member / I1101, so you can also disable that message alone.
For attributes created at runtime, list them with generated-members:
$ pylint --generated-members=cv2.LINE_AA,sphinx.generated_member
Created by the typecheck checker.