mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
sub_modules_dict improvement
This commit is contained in:
@@ -37,7 +37,7 @@ class ModuleName(ContextNameMixin, AbstractNameDefinition):
|
|||||||
|
|
||||||
class SubModuleDictMixin(object):
|
class SubModuleDictMixin(object):
|
||||||
@evaluator_method_cache()
|
@evaluator_method_cache()
|
||||||
def _sub_modules_dict(self):
|
def sub_modules_dict(self):
|
||||||
"""
|
"""
|
||||||
Lists modules in the directory of this module (if this module is a
|
Lists modules in the directory of this module (if this module is a
|
||||||
package).
|
package).
|
||||||
@@ -80,7 +80,7 @@ class ModuleMixin(SubModuleDictMixin):
|
|||||||
),
|
),
|
||||||
GlobalNameFilter(self, self.tree_node),
|
GlobalNameFilter(self, self.tree_node),
|
||||||
)
|
)
|
||||||
yield DictFilter(self._sub_modules_dict())
|
yield DictFilter(self.sub_modules_dict())
|
||||||
yield DictFilter(self._module_attributes_dict())
|
yield DictFilter(self._module_attributes_dict())
|
||||||
for star_filter in self.iter_star_filters():
|
for star_filter in self.iter_star_filters():
|
||||||
yield star_filter
|
yield star_filter
|
||||||
|
|||||||
@@ -20,6 +20,23 @@ class StubModuleContext(_StubContextMixin, ModuleContext):
|
|||||||
super(StubModuleContext, self).__init__(*args, **kwargs)
|
super(StubModuleContext, self).__init__(*args, **kwargs)
|
||||||
self.non_stub_context_set = non_stub_context_set
|
self.non_stub_context_set = non_stub_context_set
|
||||||
|
|
||||||
|
def sub_modules_dict(self):
|
||||||
|
"""
|
||||||
|
We have to overwrite this, because it's possible to have stubs that
|
||||||
|
don't have code for all the child modules. At the time of writing this
|
||||||
|
there are for example no stubs for `json.tool`.
|
||||||
|
"""
|
||||||
|
names = {}
|
||||||
|
for context in self.non_stub_context_set:
|
||||||
|
try:
|
||||||
|
method = context.sub_modules_dict
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
names.update(method())
|
||||||
|
names.update(super(StubModuleContext, self).sub_modules_dict())
|
||||||
|
return names
|
||||||
|
|
||||||
def _get_first_non_stub_filters(self):
|
def _get_first_non_stub_filters(self):
|
||||||
for context in self.non_stub_context_set:
|
for context in self.non_stub_context_set:
|
||||||
yield next(context.get_filters(search_global=False))
|
yield next(context.get_filters(search_global=False))
|
||||||
|
|||||||
Reference in New Issue
Block a user