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

Support overloaded definitions. #20

Closed
zero323 opened this issue Sep 12, 2019 · 1 comment
Closed

Support overloaded definitions. #20

zero323 opened this issue Sep 12, 2019 · 1 comment

Comments

@zero323
Copy link

zero323 commented Sep 12, 2019

It seems like at this point retype doesn't support overloaded annotations. Tested with example annotation (foo.pyi):

from typing import overload

@overload
def f(x: str) -> str: ...
@overload
def f(x: int) -> int: ...

and source file (foo.py)

def f(x):
    if isinstance(x, (str, int)):
        return x
    else:
        raise TypeError(f"x should be str or int, got {type(x)}")

Executing retype results in

error: /path/to/foo.py: Annotation problem in function 'f': 1:1: incompatible existing annotation for {arg.arg!r}. Expected: 'int', actual: 'str'

Expected output would be

from typing import overload

@overload 
def f(x: str) -> str: ...
@overload
def f(x: int) -> int: ...
def f(x):
    if isinstance(x, (str, int)):
        return x
    else:
        raise TypeError(f"x should be str or int, got {type(x)}")

or equivalent.

@gaborbernat
Copy link
Collaborator

This project is being retired and archived, so we'll no longer address this.

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

2 participants