diff --git a/jedi/evaluate/finder.py b/jedi/evaluate/finder.py index 68fcd3d9..26207f5c 100644 --- a/jedi/evaluate/finder.py +++ b/jedi/evaluate/finder.py @@ -476,8 +476,10 @@ def get_names_of_scope(evaluator, scope, position=None, star_search=True, includ in_func_scope = scope non_flow = scope.get_parent_until(pr.Flow, reverse=True) while scope: - if isinstance(scope, pr.SubModule) and scope.parent: - # we don't want submodules to report if we have modules. + # We don't want submodules to report if we have modules. + # As well as some non-scopes, which are parents of list comprehensions. + if isinstance(scope, pr.SubModule) and scope.parent \ + or not isinstance(scope, pr.IsScope): scope = scope.parent continue # `pr.Class` is used, because the parent is never `Class`. diff --git a/test/completion/basic.py b/test/completion/basic.py index 0f6d2773..7a07a7dd 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -151,6 +151,10 @@ def listen(arg): x listen(['' for x in [1]]) +#? str() +([str for x in []])[0] + + # ----------------- # nested list comprehensions # -----------------