-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RUF006 does not catch violations in lambda expressions #13619
Comments
Thanks for the report. This is a bit tricky, as the return value of Implementation-wise, I tried adding this rule to the existing expression visitor but this causes a bunch of false positives when the variable is assigned. I think we need to write a I wrote some test cases f = lambda *args: asyncio.create_task(foo())
f = lambda *args: lambda *args: asyncio.create_task(foo())
f = lambda *args: [asyncio.create_task(foo()) for x in args] |
Thanks for taking a look, the more specific use case I have where I ran into this is signal handling. The example (which does not assign the lambda to anything)
Ruff does not report an error for this which prompted me to raise this bug. But thinking about this some more, I was not understanding lambdas correctly. I had thought the lambda expression
And ruff emits an error:
But actually the lambda returns the value - so an equivalent function is this:
Ruff does not emit an error for this, because the reference is returned (not lost), right? Whether or not that reference is later dropped or not seems to be outside of the scope of |
Thanks for following up! |
Ruff does not appear to find violations for rule
RUF006
(link) in lambda expressions. Example below:List of keywords searched before opening:
RUF006
,lambda
Minimal code snippet:
sandbox.py
Command invoked:
ruff check --select RUF006 --isolated sandbox.py
Current ruff settings
N/A - overridden in command
Ruff version
ruff 0.6.7
The text was updated successfully, but these errors were encountered: