Closed dargueta closed 2 years ago
How to solve this is actually quite complex. Some options:
Pedantically, overloads are neither stubs nor abstract functions, as they're purely a form of type annotation designed to get around an ambiguity that would result without it. By that token, in my opinion, they should be treated like ordinary annotations and always be ignored.
I've never written a flake8 plugin so have no idea how easy it is to check if a function is marked with the overload decorator. The documentation is less than fantastic too. I guess the easiest way to implement this would be option 4, and rely on flake8 or other plugins to catch the edge case where someone accidentally copy-pasted the same name twice on two non-overload functions.
I decided to bite the bullet and just implement this as a third option - you can now use --unused-arguments-ignore-overload-functions
to ignore anything decorated with @overload
. I've released 0.0.11 with this.
Thank you!
If you use the @overload decorator for specific type annotations, they get counted as regular functions.
Result:
Theoretically this would also be solved by fixing #9 and using
unused-arguments-ignore-stub-functions = true
, but considering it's technically a type annotation, I think it should be completely ignored.Environment and setup is the same as #9