diff --git a/jedi/plugins/typeshed.py b/jedi/plugins/typeshed.py index 85035cc9..17c1a314 100644 --- a/jedi/plugins/typeshed.py +++ b/jedi/plugins/typeshed.py @@ -10,6 +10,7 @@ from jedi.evaluate.base_context import ContextSet, iterator_to_context_set from jedi.evaluate.filters import AbstractTreeName, ParserTreeFilter, \ TreeNameDefinition from jedi.evaluate.context import ModuleContext, FunctionContext, ClassContext +from jedi.evaluate.compiled import CompiledObject from jedi.evaluate.syntax_tree import tree_name_to_contexts from jedi.evaluate.utils import to_list @@ -127,6 +128,11 @@ class TypeshedPlugin(BasePlugin): else parent_module_context, sys_path ) + # Don't use CompiledObjects, they are just annoying and don't + # really help with anything. Just use the stub files instead. + context_set = ContextSet.from_iterable( + c for c in context_set if not isinstance(c, CompiledObject) + ) import_name = import_names[-1] map_ = None if len(import_names) == 1 and import_name != 'typing': diff --git a/test/test_plugin/test_stub.py b/test/test_plugin/test_stub.py index e5c8ce91..468f7c6a 100644 --- a/test/test_plugin/test_stub.py +++ b/test/test_plugin/test_stub.py @@ -79,3 +79,10 @@ def test_method(Script): context = def_._name._context assert isinstance(context, CompiledInstance) assert context.class_context.py__name__() == 'str' + + +def test_math(Script): + def_, = Script('import math; math.acos()').goto_definitions() + assert def_.name == 'float' + context = def_._name._context + assert context