From 39162de2a8e2e7ddf6ce005fb709b476160fe08b Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 5 Sep 2018 01:49:19 +0200 Subject: [PATCH] Some more minor adaptions --- jedi/api/classes.py | 6 ++++-- jedi/plugins/typeshed.py | 32 +++++++++++++++++--------------- jedi/settings.py | 1 - 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/jedi/api/classes.py b/jedi/api/classes.py index b6b18639..894a66a1 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -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 diff --git a/jedi/plugins/typeshed.py b/jedi/plugins/typeshed.py index adf842dc..41dcd34d 100644 --- a/jedi/plugins/typeshed.py +++ b/jedi/plugins/typeshed.py @@ -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 diff --git a/jedi/settings.py b/jedi/settings.py index 436fadfc..7b7de1be 100644 --- a/jedi/settings.py +++ b/jedi/settings.py @@ -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 ] """