Spurious "redefinition of unused" for singledispatch implementations

Bug #1658400 reported by Antony Lee
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Pyflakes
New
Undecided
Unassigned

Bug Description

Consider the following example, straight from the official docs for `functools.singledispatch` (https://docs.python.org/3.5/library/functools.html#functools.singledispatch):

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("Strength in numbers, eh?", end=" ")
    print(arg)
@fun.register(list)
def _(arg, verbose=False):
    if verbose:
        print("Enumerate this:")
    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?)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.