mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

## Summary Ensures that `x in [y, z]` does not trigger in `x`, `y`, or `z` are known _not_ to be hashable. Closes https://github.com/astral-sh/ruff/issues/9928.
15 lines
372 B
Python
15 lines
372 B
Python
# Errors
|
|
1 in [1, 2, 3]
|
|
1 in (1, 2, 3)
|
|
1 in (
|
|
1, 2, 3
|
|
)
|
|
fruits = ["cherry", "grapes"]
|
|
"cherry" in fruits
|
|
_ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in ("a", "b")}
|
|
|
|
# OK
|
|
fruits in [[1, 2, 3], [4, 5, 6]]
|
|
fruits in [1, 2, 3]
|
|
1 in [[1, 2, 3], [4, 5, 6]]
|
|
_ = {key: value for key, value in {"a": 1, "b": 2}.items() if key in (["a", "b"], ["c", "d"])}
|