-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[flake8-comprehensions] Account for list and set comprehensions in unnecessary-literal-within-tuple-call
(C409
)
#12657
Conversation
CodSpeed Performance ReportMerging #12657 will not alter performanceComparing Summary
|
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
C409 | 7 | 7 | 0 | 0 | 0 |
...comprehensions/snapshots/ruff_linter__rules__flake8_comprehensions__tests__C409_C409.py.snap
Outdated
Show resolved
Hide resolved
I'd argue this is only safe to flag for list comprehensions as set comprehensions will dedup and potentially reorder elements as well (not that you should rely on that nondeterm ordering but still). |
Good point! Another thing I noticed is that the suggestion text doesn't make sense in the context of comprehensions. I'll fix both next time I'm in front of a computer. Thanks! |
Ok, should be good to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! (FYI I had to move this behavior to preview to adhere to our versioning policy since it's an expansion in scope.)
I find this kind of thing unfortunate, because There's no way to configure ruff to disambiguate between the two. |
Summary
Make it a violation of
C409
to calltuple
with a list or set comprehension, andimplement the (unsafe) fix of calling the
tuple
with the underlying generator instead.Closes #12648.
Test Plan
Test fixture updated, cargo test, docs checked for updated description.