-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Delayed attribute assignment to object() may cause incorrect inference of instance attributes #945
Milestone
Comments
Minimal case: class Example:
def func(self):
pass
whatthe = object()
whatthe.func = None
ex = Example()
ex.func() # false-positive: not-callable |
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 13, 2021
2 tasks
nelfin
changed the title
False-positive not-callable in pylint on some methods when
Delayed attribute assignment to object() may cause incorrect inference of instance attributes
Apr 13, 2021
typing
module is imported
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 13, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 13, 2021
Ref pylint-dev#945, pylint#4232, pylint#3970, pylint#3595. Various interactions had been previously noticed with the typing/collections modules and methods named prev/next on objects. This was due to inference setting these values as instance attributes on the builtin object class due to a sentinel object and an incorrectly inferred return value in the OrderedDict definition. This change updates _can_assign_attr (and the resulting delayed_assattr behaviour) to ignore attempts to assign to object() since these would fail.
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
Apr 13, 2021
Merged
4 tasks
nelfin
added a commit
to nelfin/pylint
that referenced
this issue
Apr 13, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 21, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
Apr 21, 2021
Ref pylint-dev#945, pylint#4232, pylint#3970, pylint#3595. Various interactions had been previously noticed with the typing/collections modules and methods named prev/next on objects. This was due to inference setting these values as instance attributes on the builtin object class due to a sentinel object and an incorrectly inferred return value in the OrderedDict definition. This change updates _can_assign_attr (and the resulting delayed_assattr behaviour) to ignore attempts to assign to object() since these would fail.
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
nelfin
added a commit
to nelfin/astroid
that referenced
this issue
May 11, 2021
Ref pylint-dev#945, pylint#4232, pylint#3970, pylint#3595. Various interactions had been previously noticed with the typing/collections modules and methods named prev/next on objects. This was due to inference setting these values as instance attributes on the builtin object class due to a sentinel object and an incorrectly inferred return value in the OrderedDict definition. This change updates _can_assign_attr (and the resulting delayed_assattr behaviour) to ignore attempts to assign to object() since these would fail.
hippo91
pushed a commit
that referenced
this issue
May 11, 2021
* Add tests of expected behaviour for delayed attr assign Ref #945 * Update _can_assign_attr to return False for builtins.object Ref #945, pylint#4232, pylint#3970, pylint#3595. Various interactions had been previously noticed with the typing/collections modules and methods named prev/next on objects. This was due to inference setting these values as instance attributes on the builtin object class due to a sentinel object and an incorrectly inferred return value in the OrderedDict definition. This change updates _can_assign_attr (and the resulting delayed_assattr behaviour) to ignore attempts to assign to object() since these would fail. * Fix test definition for MRO inference * Update changelog
cdce8p
pushed a commit
to pylint-dev/pylint
that referenced
this issue
May 30, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cdce8p:
aiohttp
andVLCTelnet
turned out to be red herrings. This case fails on current stable versions:Originally posted by @nelfin in #927 (comment)
I've bisected this down to 78d5537. Pylint 2.3.1 passes this case with 20a7ae5 and fails with 78d5537
The text was updated successfully, but these errors were encountered: