summaryrefslogtreecommitdiff
path: root/astroid/brain/brain_attrs.py
diff options
context:
space:
mode:
authorTomas Gavenciak <gavento@ucw.cz>2018-12-11 14:49:29 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2018-12-12 08:53:20 +0100
commit393a8a7fc4244878ee82943214ee6bdc5a416cf8 (patch)
treeb5f566f7423d86ad3ba8d512aa49101c618b1dd8 /astroid/brain/brain_attrs.py
parent53350eef90acdf274b8129cdfb742d5bf3b01081 (diff)
downloadastroid-git-393a8a7fc4244878ee82943214ee6bdc5a416cf8.tar.gz
Extend detection of classes defined with attr
Diffstat (limited to 'astroid/brain/brain_attrs.py')
-rw-r--r--astroid/brain/brain_attrs.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/astroid/brain/brain_attrs.py b/astroid/brain/brain_attrs.py
index 74d1aa34..3bcfb852 100644
--- a/astroid/brain/brain_attrs.py
+++ b/astroid/brain/brain_attrs.py
@@ -11,12 +11,11 @@ import astroid
from astroid import MANAGER
-ATTR_IB = "attr.ib"
+ATTRIB_NAMES = frozenset(("attr.ib", "attrib", "attr.attrib"))
+ATTRS_NAMES = frozenset(("attr.s", "attrs", "attr.attrs", "attr.attributes"))
-def is_decorated_with_attrs(
- node, decorator_names=("attr.s", "attr.attrs", "attr.attributes")
-):
+def is_decorated_with_attrs(node, decorator_names=ATTRS_NAMES):
"""Return True if a decorated node has
an attr decorator applied."""
if not node.decorators:
@@ -41,7 +40,7 @@ def attr_attributes_transform(node):
if not isinstance(cdefbodynode, astroid.Assign):
continue
if isinstance(cdefbodynode.value, astroid.Call):
- if cdefbodynode.value.func.as_string() != ATTR_IB:
+ if cdefbodynode.value.func.as_string() not in ATTRIB_NAMES:
continue
else:
continue