mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:42:02 +00:00

## 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.
44 lines
500 B
Python
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]
|
|
}
|
|
)
|