It is a common idiom at my company to assign to the underscore var as a way to explicitly indicate a variable is unused. For example, you might have a method that overrides a base class method but which contains vars your implementation doesn't need:
This makes it clear to the reader that the variable is being deliberately ignored and silences pylint. It would be nice if pep8 also recognized this convention. I'd like to propose a one line change that achieves this result:
diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 7055832..5bbc6b5 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -211,7 +211,7 @@ class FunctionScope(Scope):
@ivar globals: Names declared 'global' in this function.
"""
usesLocals = False
- alwaysUsed = set(['__tracebackhide__',
+ alwaysUsed = set(['_', '__tracebackhide__', '__traceback_info__', '__traceback_supplement__'])
It is a common idiom at my company to assign to the underscore var as a way to explicitly indicate a variable is unused. For example, you might have a method that overrides a base class method but which contains vars your implementation doesn't need:
def MethodX(self, needed_var, unneeded_var):
_ = unneeded_var
...
This makes it clear to the reader that the variable is being deliberately ignored and silences pylint. It would be nice if pep8 also recognized this convention. I'd like to propose a one line change that achieves this result:
diff --git a/pyflakes/ checker. py b/pyflakes/ checker. py checker. py checker. py Scope): _tracebackhide_ _', e__',
'__traceback_ info__' , '__traceback_ supplement_ _'])
index 7055832..5bbc6b5 100644
--- a/pyflakes/
+++ b/pyflakes/
@@ -211,7 +211,7 @@ class FunctionScope(
@ivar globals: Names declared 'global' in this function.
"""
usesLocals = False
- alwaysUsed = set(['_
+ alwaysUsed = set(['_', '__tracebackhid
def __init__(self):