diff options
Diffstat (limited to 'astroid/nodes/node_classes.py')
| -rw-r--r-- | astroid/nodes/node_classes.py | 31 |
1 files changed, 3 insertions, 28 deletions
diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index e087b91b..fed043bd 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -57,6 +57,7 @@ from astroid.exceptions import ( UseInferenceDefault, ) from astroid.manager import AstroidManager +from astroid.nodes.const import OP_PRECEDENCE if sys.version_info >= (3, 8): from typing import Literal @@ -241,31 +242,6 @@ def _container_getitem(instance, elts, index, context=None): raise AstroidTypeError("Could not use %s as subscript index" % index) -OP_PRECEDENCE = { - op: precedence - for precedence, ops in enumerate( - [ - ["Lambda"], # lambda x: x + 1 - ["IfExp"], # 1 if True else 2 - ["or"], - ["and"], - ["not"], - ["Compare"], # in, not in, is, is not, <, <=, >, >=, !=, == - ["|"], - ["^"], - ["&"], - ["<<", ">>"], - ["+", "-"], - ["*", "@", "/", "//", "%"], - ["UnaryOp"], # +, -, ~ - ["**"], - ["Await"], - ] - ) - for op in ops -} - - class NodeNG: """A node of the new Abstract Syntax Tree (AST). @@ -451,7 +427,7 @@ class NodeNG: yield attr yield from () - def last_child(self): # -> Optional["NodeNG"] + def last_child(self) -> Optional["NodeNG"]: """An optimized version of list(get_children())[-1]""" for field in self._astroid_fields[::-1]: attr = getattr(self, field) @@ -611,8 +587,7 @@ class NodeNG: last_child = self.last_child() if last_child is None: return self.fromlineno - - return last_child.tolineno + return last_child.tolineno # pylint: disable=no-member def _fixed_source_line(self) -> Optional[int]: """Attempt to find the line that this node appears on. |
