Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flake8: ignore F841 unused variable for double underscore `__` on whole project

Tags:

python

flake8

I use double underscore __ as my dump variable instead of _, like so:

needed_value, __ = do_stuff()
use_value(needed_value)

However, flake8 complains as it think I'm not using this variable. That's true, but it's on purpose.

Any way to silent flake8 for this particular use case ?

A #noqa is possible but I'd like an option to do this on the whole project

like image 702
ogr Avatar asked Nov 04 '25 03:11

ogr


1 Answers

the code you pasted does not produce an error

the underlying plugin pyflakes will only produce F841 for normal assignments, not unpackings as you've written

this must mean that you have code that looks like:

def f():
    __ = foo()

which in that case, there's no reason for your dump variable and you should rewrite it to remove __ =


disclaimer: I'm the current flake8 maintainer and I'm one of the pyflakes maintainers

like image 143
Anthony Sottile Avatar answered Nov 05 '25 17:11

Anthony Sottile