summaryrefslogtreecommitdiff
path: root/astroid/brain/brain_attrs.py
diff options
context:
space:
mode:
authorBryce Guinta <bryce.paul.guinta@gmail.com>2018-02-20 20:27:50 -0700
committerBryce Guinta <bryce.paul.guinta@gmail.com>2018-02-20 20:47:56 -0700
commite686b736eb00c695d55709c612bfd64ed696388e (patch)
treef380459fb9ef014cea349dd7846137bdd06b6619 /astroid/brain/brain_attrs.py
parent3fae32f99c7f432a1281b151ea17e163a2e8dc47 (diff)
downloadastroid-git-e686b736eb00c695d55709c612bfd64ed696388e.tar.gz
Add attrs special attribute to prevent false positve in pylint
Astroid cannot infer this attribute because of the way attr builds its classes Close PyCQA/pylint#1884
Diffstat (limited to 'astroid/brain/brain_attrs.py')
-rw-r--r--astroid/brain/brain_attrs.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/astroid/brain/brain_attrs.py b/astroid/brain/brain_attrs.py
index 2ad32987..a7f0d9f8 100644
--- a/astroid/brain/brain_attrs.py
+++ b/astroid/brain/brain_attrs.py
@@ -32,6 +32,10 @@ def attr_attributes_transform(node):
"""Given that the ClassNode has an attr decorator,
rewrite class attributes as instance attributes
"""
+ # Astroid can't infer this attribute properly
+ # Prevents https://github.com/PyCQA/pylint/issues/1884
+ node.locals["__attrs_attrs__"] = [astroid.Unknown(parent=node.body)]
+
for cdefbodynode in node.body:
if not isinstance(cdefbodynode, astroid.Assign):
continue