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

typing.overload unsupported #94

Closed
gv-collibris opened this issue Sep 3, 2020 · 2 comments · Fixed by #97
Closed

typing.overload unsupported #94

gv-collibris opened this issue Sep 3, 2020 · 2 comments · Fixed by #97
Labels
bug Something isn't working
Milestone

Comments

@gv-collibris
Copy link

Describe the bug
The use of the @overload decorator is not supported.

To Reproduce
Minimal code example to reproduce the behavior:

from typing import overload


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


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


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

will return

ANN001 Missing type annotation for function argument 'x'
def add(x, y):
        ^
ANN001 Missing type annotation for function argument 'y'
def add(x, y):
           ^
ANN201 Missing return type annotation for public function
def add(x, y):
             ^

Version Information

$ flake8 --version
3.8.3 (flake8-annotations: 2.3.0) CPython 3.6.9 on Linux

As well as your Python version:

$ python -V
Python 3.6.9
@sco1 sco1 added this to the 2.4.0 milestone Sep 3, 2020
@sco1 sco1 added the bug Something isn't working label Sep 3, 2020
@sco1 sco1 changed the title [Bug] overload unsupported overload unsupported Sep 3, 2020
@sco1 sco1 changed the title overload unsupported typing.overload unsupported Sep 3, 2020
@sco1
Copy link
Owner

sco1 commented Sep 3, 2020

Thanks for the report, this decorator wasn't something considered when originally designed. Since we keep the state of all function definitions in the file, it should be straightforward to identify the final non-decorated function.

In the meantime I think the only option is to noqa the offending lines to suppress the spurious error(s).

Edit: The --allow-untyped-defs flag could also be an interim option.

@gv-collibris
Copy link
Author

Thanks a lot for this improvement =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants