diff --git a/jedi/evaluate/finder.py b/jedi/evaluate/finder.py index 7f998d8f..e5727821 100644 --- a/jedi/evaluate/finder.py +++ b/jedi/evaluate/finder.py @@ -88,7 +88,7 @@ class NameFinder(object): # Just calculate the scope from the first stmt = names[0].get_definition() scope = stmt.get_parent_scope() - if isinstance(stmt, (pr.CompFor, pr.Lambda)): + if isinstance(stmt, (pr.CompFor, pr.Lambda, pr.GlobalStmt)): return names # Private name mangling (compile.c) disallows access on names diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index 050dec46..59bad818 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -211,8 +211,8 @@ class FakeName(pr.Name): class LazyName(FakeName): - def __init__(self, name, parent_callback): - super(LazyName, self).__init__(name) + def __init__(self, name, parent_callback, is_definition=None): + super(LazyName, self).__init__(name, is_definition=is_definition) self._parent_callback = parent_callback @property diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index baa4237a..f4db1205 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -848,7 +848,8 @@ class ModuleWrapper(use_metaclass(CachedMetaClass, pr.Module, Wrapper)): names = ['__file__', '__package__', '__doc__', '__name__'] # All the additional module attributes are strings. - return dict((n, [helpers.LazyName(n, parent_callback)]) for n in names) + return dict((n, [helpers.LazyName(n, parent_callback, is_definition=True)]) + for n in names) @memoize_default() def _module_attributes(self):