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
Add support for attrs v21.3.0+ #1331
Changes from 1 commit
aef4130
d4a7bd8
2e164f3
3119997
2e7cefe
b2b038b
f95d7ea
1564691
e1d02eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,22 @@ | |
from astroid.nodes.node_classes import AnnAssign, Assign, AssignName, Call, Unknown | ||
from astroid.nodes.scoped_nodes import ClassDef | ||
|
||
ATTRIB_NAMES = frozenset(("attr.ib", "attrib", "attr.attrib", "attr.field", "field")) | ||
ATTRIB_NAMES = frozenset( | ||
("attr.ib", "attrib", "attr.attrib", "attr.field", "attrs.field", "field") | ||
) | ||
ATTRS_NAMES = frozenset( | ||
( | ||
"attr.s", | ||
"attrs", | ||
"define", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should add this. Sadly this brain does not infer the actual function behind the decorator but only looks at the name. However, if anybody uses Do we want to add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well I don't like assuming that something is part of a lib only because of its name especially since we have inference capability in astroid. I know we're doing it for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Pierre-Sassoulas i agree with you and @DanielNoord as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, I've removed |
||
"attr.attrs", | ||
"attr.attributes", | ||
"attr.define", | ||
"attr.mutable", | ||
"attr.frozen", | ||
"attrs.define", | ||
"attrs.mutable", | ||
"attrs.frozen", | ||
) | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could discuss if
attrib
andfield
should be in this list but that ship has sailed I think.Thanks for removing
define
! 👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, it's also a problem.
Suggestion done in order to check if it's causing test fails. Imo we can most probably not infer the value as aliasing of attrs must be rare considering it's a small name, but we also should infer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like it breaks the existing
test_attr_transform
as well as the newly addedtest_attrs_transform
.Also there's a regression test in
pylint
that also relies on the existingattrib
; https://github.com/PyCQA/pylint/blob/main/tests/functional/r/regression/regression_4439.pyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pierre-Sassoulas Let's revert then. Thanks @jacobbogdanov for checking this out.