diff --git a/jedi/parser_utils.py b/jedi/parser_utils.py index c8998fa4..1a68ca4a 100644 --- a/jedi/parser_utils.py +++ b/jedi/parser_utils.py @@ -259,11 +259,9 @@ def get_parent_scope(node, include_flows=False): return None # It's a module already. if scope.type in ('funcdef', 'classdef') and scope.name == node: scope = scope.parent - if scope.parent is None: # The module scope. - return scope while True: - if include_flows and isinstance(scope, tree.Flow) or is_scope(scope): + if is_scope(scope) or include_flows and isinstance(scope, tree.Flow): return scope scope = scope.parent return scope