-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive for no-member with property setters #9811
Labels
Astroid
Related to astroid
Needs astroid update
Needs an astroid update (probably a release too) before being mergable
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
properties
Regression
Milestone
Comments
mdegat01
added
the
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
label
Jul 17, 2024
Sorry for the complexity of the example. It did not appear unless I added in the inheritance model and a multi-level nested reference matching what is used in the project I was working on when I discovered it. |
12 tasks
Thanks for the report. Regression in pylint-dev/astroid@0f9dfa6. |
jacobtylerwalls
added
Astroid
Related to astroid
Regression
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
and removed
Needs triage 📥
Just created, needs acknowledgment, triage, and proper labelling
labels
Jul 23, 2024
jacobtylerwalls
changed the title
False positive for no-member, new in 3.12.4
False positive for no-member with property setters
Jul 24, 2024
I'm doubtful this is the best thing we can do, but a quick-n-dirty might be some variation of: diff --git a/astroid/nodes/scoped_nodes/scoped_nodes.py b/astroid/nodes/scoped_nodes/scoped_nodes.py
index efd5439b..dbe5872e 100644
--- a/astroid/nodes/scoped_nodes/scoped_nodes.py
+++ b/astroid/nodes/scoped_nodes/scoped_nodes.py
@@ -2495,6 +2495,16 @@ class ClassDef( # pylint: disable=too-many-instance-attributes
if attr.parent and attr.parent.scope() == first_scope
]
functions = [attr for attr in attributes if isinstance(attr, FunctionDef)]
+ setter = None
+ for function in functions:
+ dec_names = function.decoratornames(context=context)
+ for dec_name in dec_names:
+ if dec_name is util.Uninferable:
+ continue
+ if dec_name.split(".")[-1] == "setter":
+ setter = function
+ if setter:
+ break
if functions:
# Prefer only the last function, unless a property is involved.
last_function = functions[-1]
@@ -2518,7 +2528,7 @@ class ClassDef( # pylint: disable=too-many-instance-attributes
elif isinstance(inferred, objects.Property):
function = inferred.function
if not class_context:
- if not context.callcontext:
+ if not context.callcontext and not setter:
context.callcontext = CallContext(
args=function.args.arguments, callee=function
) |
jacobtylerwalls
added
the
Needs astroid update
Needs an astroid update (probably a release too) before being mergable
label
Jul 24, 2024
Slimmer reproducer: # pylint: disable=missing-module-docstring,missing-class-docstring, missing-function-docstring
class BugReport:
@property
def host(self):
return self._host
@host.setter
def host(self, value: str):
self._host = value
@property
def timezone(self):
return self.host.lower() # self.host should not infer as self ************* Module a
Desktop/a.py:14:15: E1101: Instance of 'BugReport' has no 'lower' member (no-member) |
jacobtylerwalls
added a commit
to pylint-dev/astroid
that referenced
this issue
Sep 19, 2024
jacobtylerwalls
added a commit
to jacobtylerwalls/astroid
that referenced
this issue
Sep 19, 2024
Closes pylint-dev/pylint#9811 (cherry picked from commit 5a93a9f)
jacobtylerwalls
added a commit
to pylint-dev/astroid
that referenced
this issue
Sep 19, 2024
Closes pylint-dev/pylint#9811 (cherry picked from commit 5a93a9f)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Astroid
Related to astroid
Needs astroid update
Needs an astroid update (probably a release too) before being mergable
Needs PR
This issue is accepted, sufficiently specified and now needs an implementation
properties
Regression
Bug description
Configuration
No response
Command used
Pylint output
Expected behavior
This should not show an error, all members referenced are defined. Notably it does not show an error in 3.12.3, appears to be a regression with 3.12.4
Pylint version
OS / Environment
MacOS 14.4.1
We also are seeing it in ubuntu containers running in github actions, like this run: https://github.com/home-assistant/supervisor/actions/runs/9904839873/job/27515699355 (same issue, appeared on upgrade to 3.12.4).
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: