Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore lambda arguments for B020 #259

Merged
merged 2 commits into from May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions bugbear.py
Expand Up @@ -824,6 +824,11 @@ def visit_DictComp(self, node):
def visit_comprehension(self, node):
self.visit(node.iter)

def visit_Lambda(self, node):
self.visit(node.body)
for lambda_arg in node.args.args:
self.names.pop(lambda_arg.arg, None)


error = namedtuple("error", "lineno col message type vars")
Error = partial(partial, error, type=BugBearChecker, vars=())
Expand Down
3 changes: 3 additions & 0 deletions tests/b020.py
Expand Up @@ -35,3 +35,6 @@
# However we still call out reassigning the iterable in the comprehension.
for vars in [i for i in vars]:
print(vars)

for var in sorted(range(10), key=lambda var: var.real):
print(var)