davidhalter / jedi

Awesome autocompletion, static analysis and refactoring library for python
http://jedi.readthedocs.io
Other
5.77k stars 508 forks source link

@typing.overload decorator not supported; only @overload #1840

Open C-SELLERS opened 2 years ago

C-SELLERS commented 2 years ago

Using Jedi as Python Language Server for VSCode I have some issues I am seeing with autocomplete from a stubs module that has various overloads.

In the stubs module itself I see the decorators @typing.overload on each of the overloads. The autocomplete feature for Pylance loads all these overloads and shows them to me. For Jedi however, it only shows one implementation.

In testing I changed a few from @typing.overload to @overload and then it worked. I could see all the implementation is autocomplete, even without from typing import overload in the module.

So it seems Jedi, may not recognize the typing namespace as a valid part of the overload decorator. I might assume this applies to other typing decorators as well.

davidhalter commented 2 years ago

The bug only affects overload, because for performance reasons we do not fully infer here.

If you want to fix it, it's probably not that hard, just check jedi/inference/value/function.py _find_overload_functions and play with that function a bit.