ruff/crates/ruff_linter/resources/test/fixtures/flake8_comprehensions/C409.py
Dylan 25aabec814
[flake8-comprehensions] Account for list and set comprehensions in unnecessary-literal-within-tuple-call (C409) (#12657)
## Summary

Make it a violation of `C409` to call `tuple` with a list or set
comprehension, and
implement 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.
2024-08-04 22:14:52 -04:00

44 lines
500 B
Python

t1 = tuple([])
t2 = tuple([1, 2])
t3 = tuple((1, 2))
t4 = tuple([
1,
2
])
t5 = tuple(
(1, 2)
)
tuple( # comment
[1, 2]
)
tuple([ # comment
1, 2
])
tuple((
1,
))
t6 = tuple([1])
t7 = tuple((1,))
t8 = tuple([1,])
tuple([x for x in range(5)])
tuple({x for x in range(10)})
tuple(x for x in range(5))
tuple([
x for x in [1,2,3]
])
tuple( # comment
[x for x in [1,2,3]]
)
tuple([ # comment
x for x in range(10)
])
tuple(
{
x for x in [1,2,3]
}
)