summaryrefslogtreecommitdiff
path: root/astroid/node_classes.py
diff options
context:
space:
mode:
Diffstat (limited to 'astroid/node_classes.py')
-rw-r--r--astroid/node_classes.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/astroid/node_classes.py b/astroid/node_classes.py
index b9af5983..994c96bd 100644
--- a/astroid/node_classes.py
+++ b/astroid/node_classes.py
@@ -496,7 +496,9 @@ class NodeNG:
:returns: The first parent scope node.
:rtype: Module or FunctionDef or ClassDef or Lambda or GenExpr
"""
- return self.parent.scope()
+ if self.parent:
+ return self.parent.scope()
+ return None
def root(self):
"""Return the root node of the syntax tree.