From 9cbfb76eb53ba8705cb7665746a127e592639296 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sat, 17 Dec 2016 17:46:21 +0100 Subject: [PATCH] Fix getting the names for specific scopes in jedi.names. --- jedi/evaluate/helpers.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index 7debba2d..8e1ae2ed 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -165,12 +165,14 @@ def get_module_names(module, all_scopes): Returns a dictionary with name parts as keys and their call paths as values. """ - if all_scopes: - dct = module.used_names - else: - raise DeprecationWarning - dct = module.names_dict - return chain.from_iterable(dct.values()) + names = chain.from_iterable(module.used_names.values()) + if not all_scopes: + # We have to filter all the names that don't have the module as a + # parent_scope. There's None as a parent, because nodes in the module + # node have the parent module and not suite as all the others. + # Therefore it's important to catch that case. + names = [n for n in names if n.get_parent_scope().parent in (module, None)] + return names class FakeName(tree.Name):