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
self._module = name.get_root_context()
if self.in_builtin_module():
try:
py__file__ = self._module.py__file__
except AttributeError:
self.module_path = None
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``"""
@property

View File

@@ -260,11 +260,16 @@ class StubParserTreeFilter(ParserTreeFilter):
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):
non_stub_filters += f._filters
else:
non_stub_filters.append(f)
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:
if key_name not in used_stub_names:
result_names += non_stub_filter.get(key_name)
@@ -377,28 +382,25 @@ class StubOnlyModuleContext(ModuleContext):
def _get_first_non_stub_filters(self):
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,
origin_scope=None, **kwargs):
filters = super(StubOnlyModuleContext, self).get_filters(
search_global, until_position, origin_scope, **kwargs
)
first_non_stub_filters = list(self._get_first_non_stub_filters())
next(filters) # Ignore the first filter and replace it with our own
if first_non_stub_filters:
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
# important if type inferences is needed in that module.
yield StubParserTreeFilter(
list(self._get_first_non_stub_filters()),
self.evaluator,
context=self,
until_position=until_position,
origin_scope=origin_scope,
search_global=search_global,
)
# Here we remap the names from stubs to the actual module. This is
# important if type inferences is needed in that module.
yield StubParserTreeFilter(
list(self._get_first_non_stub_filters()),
self.evaluator,
context=self,
until_position=until_position,
origin_scope=origin_scope,
search_global=search_global,
)
for f in filters:
yield f

View File

@@ -144,7 +144,6 @@ Check for `isinstance` and other information to infer a type.
"""
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
]
"""