You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
F811 (redefinition of unused variable) incorrectly triggered with @overload decorator #320
PEP 484 introduced the @overload decorator for type annotations.
[...] a series of @overload-decorated definitions must be followed by exactly one non-@overload-decorated definition (for the same function/method). The @overload-decorated definitions are for the benefit of the type checker only, since they will be overwritten by the non-@overload-decorated definition, while the latter is used at runtime but should be ignored by a type checker.
The following should pass PyFlakes without errors, but currently triggers F811 errors:
test.py:9:1: F811 redefinition of unused 'utf8' from line 4
test.py:14:1: F811 redefinition of unused 'utf8' from line 9
test.py:19:1: F811 redefinition of unused 'utf8' from line 14
Reacted by Nico Lehmann, Michael K., Ilya Priven, Jonathan Sudiaman, Steven Karas, alex-verve, Marius Cobzarenco, Isaac Turner, Mark Amery, Maksym and 10 more
☁ shm pyflakes a.py
a.py:11: redefinition of unused 'f' from line 6
a.py:16: redefinition of unused 'f' from line 10
☁ shm pyflakes --version
2.1.1 Python 3.6.7 on Linux
I'm now working around this by using full typing.overload name
Activity
tscholak commentedon Feb 13, 2018
facing the same issue. do you have a workaround?
bartvm commentedon Feb 13, 2018
Added this to.pydocstyle
We ended up adding `# noqa: F811` comments.sigmavirus24 commentedon Feb 13, 2018
How does pydocstyle config fix a pyflakes bug?
asottile commentedon Oct 14, 2018
I took a stab at this: #371
feisuzhu commentedon Mar 4, 2019
Hi, it's good to see #371 solved this partially, but
overloads on classes is still incorrectly triggeredI'm now working around this by using full
typing.overloadnameasottile commentedon Mar 4, 2019
@feisuzhu try master, I've already fixed this: #435
eellison commentedon Aug 6, 2019
I still have this issue when the overload decorator is wrapped by another decorator.
asottile commentedon Aug 6, 2019
that's not possible to detect statically -- I'd suggest not doing that (I don't think mypy can detect that either)
I'd suggest explicitly using the overload decorator
eellison commentedon Aug 6, 2019
Gotcha. I don't think this works either.
asottile commentedon Aug 6, 2019
Have you tried on master? it works for me
asottile commentedon Aug 6, 2019
actually, it even works with the released version of pyflakes so you're probably on an old one
eellison commentedon Aug 6, 2019
This is my version info that doesn't work:
3.7.8 (flake8-comprehensions: 2.1.0, flake8-mypy: 17.8.0, mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1) CPython 3.6.8 on LinuxWhat do you think about counting a decorator as a use of a function? Edit: the redefinition error would still exist even if the unused wouldn't
asottile commentedon Aug 6, 2019
actually, I'm wrong about it being already released -- it is fixed on master though, please try that and confirm
asottile commentedon Aug 6, 2019
see #435
eellison commentedon Aug 6, 2019
yea works on master, thanks!