diff --git a/jedi/evaluate/context/klass.py b/jedi/evaluate/context/klass.py index e0fd929d..6862a189 100644 --- a/jedi/evaluate/context/klass.py +++ b/jedi/evaluate/context/klass.py @@ -201,6 +201,13 @@ class ClassMixin(object): def py__mro__(self): return py__mro__(self) + def _create_class_filter(self, cls, origin_scope, is_instance): + return ClassFilter( + self.evaluator, self, node_context=cls, + origin_scope=origin_scope, + is_instance=is_instance + ) + def get_filters(self, search_global=False, until_position=None, origin_scope=None, is_instance=False): if search_global: @@ -216,11 +223,7 @@ class ClassMixin(object): for filter in cls.get_filters(is_instance=is_instance): yield filter else: - yield ClassFilter( - self.evaluator, self, node_context=cls, - origin_scope=origin_scope, - is_instance=is_instance - ) + yield self._create_class_filter(cls, origin_scope, is_instance) if not is_instance and self: # Return completions of the meta class. from jedi.evaluate.compiled import builtin_from_name diff --git a/jedi/evaluate/context/typing.py b/jedi/evaluate/context/typing.py index 4b1239d0..ff3d0f33 100644 --- a/jedi/evaluate/context/typing.py +++ b/jedi/evaluate/context/typing.py @@ -496,8 +496,29 @@ class AbstractAnnotatedClass(ClassMixin, ContextWrapper): def get_type_var_filter(self): return TypeVarFilter(self.get_given_types(), self.list_type_vars()) + def _create_class_filter(self, cls, origin_scope, is_instance): + filter_ = super(AbstractAnnotatedClass, self)._create_class_filter( + cls, origin_scope, is_instance + ) + try: + stub_context = cls.stub_context + except AttributeError: + return filter_ + else: + return stub_context.get_stub_only_filter( + # Take the first filter, which is here to filter module contents + # and wrap it. + [filter_], + search_global=False, + origin_scope=origin_scope, + ) + def get_filters(self, search_global=False, *args, **kwargs): - for f in super(AbstractAnnotatedClass, self).get_filters(search_global, *args, **kwargs): + filters = super(AbstractAnnotatedClass, self).get_filters( + search_global, + *args, **kwargs + ) + for f in filters: yield f if search_global: