[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 |
|
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! |
charliermarsh
left a comment
There was a problem hiding this comment.
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
C409to calltuplewith a list or set comprehension, andimplement the (unsafe) fix of calling the
tuplewith the underlying generator instead.Closes #12648.
Test Plan
Test fixture updated, cargo test, docs checked for updated description.