summaryrefslogtreecommitdiff
path: root/venv/Lib/site-packages/astroid/brain/brain_attrs.py
diff options
context:
space:
mode:
authorpravindalve2023-05-30 04:20:14 +0530
committerGitHub2023-05-30 04:20:14 +0530
commitcbdd7ca21f1f673a3a739065098f7cc6c9c4b881 (patch)
tree595e888c38f00a314e751096b6bf636a544a5efe /venv/Lib/site-packages/astroid/brain/brain_attrs.py
parent7740d1ca0c2e6bf34900460b0c58fa4d528577fb (diff)
parent280c6aa89a15331fb76b7014957953dc72af6093 (diff)
downloadChemical-Simulator-GUI-master.tar.gz
Chemical-Simulator-GUI-master.tar.bz2
Chemical-Simulator-GUI-master.zip
Merge pull request #63 from brenda-br/Fix-35HEADmaster
Restructure Project and Deployment
Diffstat (limited to 'venv/Lib/site-packages/astroid/brain/brain_attrs.py')
-rw-r--r--venv/Lib/site-packages/astroid/brain/brain_attrs.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/venv/Lib/site-packages/astroid/brain/brain_attrs.py b/venv/Lib/site-packages/astroid/brain/brain_attrs.py
deleted file mode 100644
index 670736f..0000000
--- a/venv/Lib/site-packages/astroid/brain/brain_attrs.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
-# For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
-"""
-Astroid hook for the attrs library
-
-Without this hook pylint reports unsupported-assignment-operation
-for attrs classes
-"""
-
-import astroid
-from astroid import MANAGER
-
-
-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=ATTRS_NAMES):
- """Return True if a decorated node has
- an attr decorator applied."""
- if not node.decorators:
- return False
- for decorator_attribute in node.decorators.nodes:
- if isinstance(decorator_attribute, astroid.Call): # decorator with arguments
- decorator_attribute = decorator_attribute.func
- if decorator_attribute.as_string() in decorator_names:
- return True
- return False
-
-
-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)]
-
- for cdefbodynode in node.body:
- if not isinstance(cdefbodynode, (astroid.Assign, astroid.AnnAssign)):
- continue
- if isinstance(cdefbodynode.value, astroid.Call):
- if cdefbodynode.value.func.as_string() not in ATTRIB_NAMES:
- continue
- else:
- continue
- targets = (
- cdefbodynode.targets
- if hasattr(cdefbodynode, "targets")
- else [cdefbodynode.target]
- )
- for target in targets:
-
- rhs_node = astroid.Unknown(
- lineno=cdefbodynode.lineno,
- col_offset=cdefbodynode.col_offset,
- parent=cdefbodynode,
- )
- node.locals[target.name] = [rhs_node]
- node.instance_attrs[target.name] = [rhs_node]
-
-
-MANAGER.register_transform(
- astroid.ClassDef, attr_attributes_transform, is_decorated_with_attrs
-)