Spurious "redefinition of unused" for singledispatch implementations
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Pyflakes |
New
|
Undecided
|
Unassigned |
Bug Description
Consider the following example, straight from the official docs for `functools.
from functools import singledispatch
@singledispatch
def fun(arg, verbose=False):
if verbose:
print("Let me just say,", end=" ")
print(arg)
@fun.register(int)
def _(arg, verbose=False):
if verbose:
print(arg)
@fun.register(list)
def _(arg, verbose=False):
if verbose:
for i, elem in enumerate(arg):
print(i, elem)
pyflakes 1.5.0 spuriously reports:
foo.py:13: redefinition of unused '_' from line 7
(In practice I would avoid warning on assignments to '_' as much as possible, and possible warn on *uses* of '_' as much as possible -- although it may actually be used by gettext for i18n?)