diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2023-04-01 13:12:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-01 13:12:22 +0200 |
commit | 895c6d7e847eea78a11e832429cf4a06ace93647 (patch) | |
tree | c8527b35cc3328634b83f48f13cbe065d914cb5b /astroid | |
parent | 1bc3e7603042363d1bc01f53ad6b5fe97ee18fc7 (diff) | |
download | astroid-git-895c6d7e847eea78a11e832429cf4a06ace93647.tar.gz |
Support attrs decorators even if they are imported from attrs (#2059) (#2073)
Use inference to determine membership of ``attr(s)`` module
Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
(cherry picked from commit 489c90fb29970d9362f21f26247bd45a39832dcd)
Co-authored-by: alm <alonme@users.noreply.github.com>
Diffstat (limited to 'astroid')
-rw-r--r-- | astroid/brain/brain_attrs.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/astroid/brain/brain_attrs.py b/astroid/brain/brain_attrs.py index acb069e3..7afcc8ab 100644 --- a/astroid/brain/brain_attrs.py +++ b/astroid/brain/brain_attrs.py @@ -8,6 +8,7 @@ Astroid hook for the attrs library Without this hook pylint reports unsupported-assignment-operation for attrs classes """ +from astroid.helpers import safe_infer from astroid.manager import AstroidManager from astroid.nodes.node_classes import AnnAssign, Assign, AssignName, Call, Unknown from astroid.nodes.scoped_nodes import ClassDef @@ -40,6 +41,10 @@ def is_decorated_with_attrs(node, decorator_names=ATTRS_NAMES) -> bool: decorator_attribute = decorator_attribute.func if decorator_attribute.as_string() in decorator_names: return True + + inferred = safe_infer(decorator_attribute) + if inferred and inferred.root().name == "attr._next_gen": + return True return False |