Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overloads signature #664

Closed
AmjadHD opened this issue Sep 30, 2019 · 6 comments
Closed

Overloads signature #664

AmjadHD opened this issue Sep 30, 2019 · 6 comments

Comments

@AmjadHD
Copy link

AmjadHD commented Sep 30, 2019

@overload
def add(x: int, y:int) -> int: ...

@overload
def add(x: int, y: float) -> float: ...

def add(x, y):
    return x + y

can pyls be modified send multiple signatures in this case ?

@ccordoba12
Copy link
Contributor

ccordoba12 commented Sep 30, 2019

I don't understand what the current and expected behaviors are. Please clarify.

@joreiff
Copy link

joreiff commented Oct 1, 2019

@AmjadHD
Copy link
Author

AmjadHD commented Oct 1, 2019

I have three files located in one folder:
mod.py:

def add(x, y):
    return x + y

mod.pyi:

from typing import overload


@overload
def add(x: int, y: int) -> int: ...


@overload
def add(x: int, y: float) -> float: ...

and test.py:

from mod import add


add(

when I type add( in test.py with sublime text, I get this signature help:
image
this is sublime's LSP log:

LSP:  --> textDocument/signatureHelp
LSP:      {'activeParameter': 0, 'signatures': [{'documentation': '', 'label': 'add(x: int, y: float) -> float', 'parameters': [{'documentation': None, 'label': 'x'}, {'documentation': None, 'label': 'y'}]}], 'activeSignature': 0}

you can see that signatures contains one signature only while it should contain two as described in the LSP specification
mypy does list all overloads, maybe you can use that:
image

@tomv564
Copy link
Contributor

tomv564 commented Oct 1, 2019

The spec says:

There can be multiple signature but only one active and only one active parameter.

So it's an option, not a requirement to send multiple signatures.

Mypy is not the right tool for this, it is built for type checking entire documents, not "tell me about the thing on line 50" queries.

Jedi is the library used for signature help, and it did add support for stubs in a release last summer - I think they skipped support for overloads. See: davidhalter/jedi#839

@AmjadHD
Copy link
Author

AmjadHD commented Oct 1, 2019

So it's an option, not a requirement to send multiple signatures.

yes I know it's an option this is a feature request not a bug report

Jedi is the library used for signature help, and it did add support for stubs in a release last summer - I think they skipped support for overloads. See: davidhalter/jedi#839

so should this be opened in the jedi repo ?

@ccordoba12
Copy link
Contributor

Yes. This can't be solved here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants