flake8-unused-arguments icon indicating copy to clipboard operation
flake8-unused-arguments copied to clipboard

_ variable should be ignored

Open crsegerie opened this issue 2 years ago • 7 comments

_ is a convention for variable that are not used afterwards.

crsegerie avatar May 19 '22 17:05 crsegerie

I'm not taking about _* variables, only _ variables

crsegerie avatar May 20 '22 07:05 crsegerie

So to be clear, you're saying functions like this?

def foo(a, b, c, _):
    return a + b + c

nhoad avatar May 20 '22 12:05 nhoad

More like

def foo(a, b, c):
    _ = c
    return a + b 

_ should be ignored by default

crsegerie avatar May 24 '22 08:05 crsegerie

To make sure I understand, in this case we’d ignore the assignment to _, so then the c argument would be reported unused. Is that the behavior you’d want?

nhoad avatar May 26 '22 10:05 nhoad

I'm also in for def fn(a, b, c, _) not reporting error on _

if anything, report a warning if it's actually being used

FelipeLema avatar Jul 27 '22 16:07 FelipeLema

@FelipeLema that's a different request to what's being asked for here. What you're asking for is already supported - U101 is for unused arguments that start with an underscore, so you can simply start ignoring U101.

nhoad avatar Jul 27 '22 16:07 nhoad

oh, I didn't know that... thanks for noting

FelipeLema avatar Jul 27 '22 17:07 FelipeLema