diff --git a/jedi/evaluate/context/iterable.py b/jedi/evaluate/context/iterable.py index b0ae1d54..90a0176d 100644 --- a/jedi/evaluate/context/iterable.py +++ b/jedi/evaluate/context/iterable.py @@ -76,7 +76,7 @@ class GeneratorBase(LazyAttributeOverwrite, IterableMixin): @property def name(self): - return compiled.CompiledContextName(self, 'generator') + return compiled.CompiledContextName(self, 'Generator') class Generator(GeneratorBase): diff --git a/jedi/evaluate/gradual/conversion.py b/jedi/evaluate/gradual/conversion.py index ec368459..4109a70f 100644 --- a/jedi/evaluate/gradual/conversion.py +++ b/jedi/evaluate/gradual/conversion.py @@ -1,3 +1,4 @@ +from jedi import debug from jedi.evaluate.base_context import ContextSet, \ NO_CONTEXTS from jedi.evaluate.utils import to_list @@ -49,11 +50,13 @@ def _infer_from_stub(stub_module, qualified_names, ignore_compiled): def try_stubs_to_actual_context_set(stub_contexts, prefer_stub_to_compiled=False): - return ContextSet.from_sets( + contexts = ContextSet.from_sets( stub_to_actual_context_set(stub_context, ignore_compiled=prefer_stub_to_compiled) or ContextSet([stub_context]) for stub_context in stub_contexts ) + debug.dbg('Stubs to actual: %s to %s', stub_contexts, contexts) + return contexts @to_list diff --git a/jedi/plugins/stdlib.py b/jedi/plugins/stdlib.py index 659abee7..b0203f87 100644 --- a/jedi/plugins/stdlib.py +++ b/jedi/plugins/stdlib.py @@ -575,5 +575,11 @@ _implemented = { # Not sure if this is necessary, but it's used a lot in typeshed and # it's for now easier to just pass the function. 'abstractmethod': _return_first_param, - } + }, + 'typing': { + # The _alias function just leads to some annoying type inference. + # Therefore, just make it return nothing, which leads to the stubs + # being used instead. This only matters for 3.7+. + '_alias': lambda obj, arguments: NO_CONTEXTS, + }, } diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index b770fd59..649cad57 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -128,7 +128,7 @@ def test_goto_definitions_on_non_name(Script): def test_goto_definitions_on_generator(Script): def_, = Script('def x(): yield 1\ny=x()\ny').goto_definitions() - assert def_.name == 'generator' + assert def_.name == 'Generator' def test_goto_definition_not_multiple(Script):