Some more minor adaptions

This commit is contained in:
Dave Halter
2018-09-05 01:49:19 +02:00
parent 4a3fc91c1e
commit 39162de2a8
3 changed files with 21 additions and 18 deletions

View File

@@ -65,10 +65,12 @@ class BaseDefinition(object):
# generate a path to the definition # generate a path to the definition
self._module = name.get_root_context() self._module = name.get_root_context()
if self.in_builtin_module(): try:
py__file__ = self._module.py__file__
except AttributeError:
self.module_path = None self.module_path = None
else: else:
self.module_path = self._module.py__file__() self.module_path = py__file__()
"""Shows the file path of a module. e.g. ``/usr/lib/python2.7/os.py``""" """Shows the file path of a module. e.g. ``/usr/lib/python2.7/os.py``"""
@property @property

View File

@@ -260,11 +260,16 @@ class StubParserTreeFilter(ParserTreeFilter):
non_stub_filters = [] non_stub_filters = []
for f in self._non_stub_filters: for f in self._non_stub_filters:
# TODO this is really ugly. accessing some random _used_names and
# _filters. Please change.
if isinstance(f, MergedFilter): if isinstance(f, MergedFilter):
non_stub_filters += f._filters non_stub_filters += f._filters
else: else:
non_stub_filters.append(f) non_stub_filters.append(f)
for non_stub_filter in non_stub_filters: for non_stub_filter in non_stub_filters:
if not hasattr(non_stub_filter, '_used_names'):
continue
for key_name in non_stub_filter._used_names: for key_name in non_stub_filter._used_names:
if key_name not in used_stub_names: if key_name not in used_stub_names:
result_names += non_stub_filter.get(key_name) result_names += non_stub_filter.get(key_name)
@@ -377,7 +382,6 @@ class StubOnlyModuleContext(ModuleContext):
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:
if not isinstance(context, CompiledObject):
yield next(context.get_filters(search_global=False)) yield next(context.get_filters(search_global=False))
def get_filters(self, search_global, until_position=None, def get_filters(self, search_global, until_position=None,
@@ -385,10 +389,8 @@ class StubOnlyModuleContext(ModuleContext):
filters = super(StubOnlyModuleContext, self).get_filters( filters = super(StubOnlyModuleContext, self).get_filters(
search_global, until_position, origin_scope, **kwargs search_global, until_position, origin_scope, **kwargs
) )
first_non_stub_filters = list(self._get_first_non_stub_filters())
if first_non_stub_filters:
next(filters) # Ignore the first filter and replace it with our own next(filters) # Ignore the first filter and replace it with our own
# Here we remap the names from stubs to the actual module. This is # Here we remap the names from stubs to the actual module. This is
# important if type inferences is needed in that module. # important if type inferences is needed in that module.
yield StubParserTreeFilter( yield StubParserTreeFilter(

View File

@@ -144,7 +144,6 @@ Check for `isinstance` and other information to infer a type.
""" """
auto_import_modules = [ auto_import_modules = [
'hashlib', # hashlib is mostly using setattr, which jedi doesn't understand
'gi', # This third-party repository (GTK stuff) doesn't really work with jedi 'gi', # This third-party repository (GTK stuff) doesn't really work with jedi
] ]
""" """