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

Fixing false negatives with E731 lambda assignments #1078

Closed
wants to merge 1 commit into from
Closed

Fixing false negatives with E731 lambda assignments #1078

wants to merge 1 commit into from

Conversation

Sam-Cleveland
Copy link

fixes #1061
Changed out the current implementation of lambda assignment detection for a regex based one. As stated in #1061, there are several lambda assignment cases that are being missed. Additionally, the current detection implementation is not in the most logical place. Before, detection of lambdas was tied to searching for ':' characters. Now lambda assignment statements are all just detected by:

(?<!\.)\w+\s*(\,\s*\w+\s*)*\=(.*\,)*[\s|\(]*lambda

This implementation has more coverage and is more simple than the previous one.

Changed out the current implementation of lambda assignment detection for a regex based one.
@asottile
Copy link
Member

I don't think this is solvable with a regex -- it needs to have a parse tree probably -- just a counter example from your proposed regex:

x = f(1, (lambda: None))

@Sam-Cleveland
Copy link
Author

Ok. Working on a solution.

@Sam-Cleveland Sam-Cleveland marked this pull request as draft June 22, 2022 19:38
@asottile
Copy link
Member

asottile commented Aug 2, 2022

oops, didn't mean to approve, was testing a user script

@Sam-Cleveland Sam-Cleveland closed this by deleting the head repository Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

E731 false negatives
2 participants