sco1/flake8-annotations

`typing.overload` unsupported

gv-collibris opened this issue · 2 comments

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 commented

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.

Thanks a lot for this improvement =)