-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
Summary
Ruff version
ruff 0.12.12
Ruff settings
PLR6201 enabled
Problem
Fix safety description of PLR6201 is misleading:
Fix safety
This rule's fix is marked as unsafe, as the use of a set literal will error at runtime if the sequence contains unhashable elements (like lists or dictionaries). While Ruff will attempt to infer the hashability of the elements, it may not always be able to do so.
This reads as if only the hashability of the rhs-sequence was the problem. But in my opinion, the hashability of the lhs is more problematic in most use cases. F.i.
def foo(val: str | list[str] | dict[str, str]) -> bool:
return val in {"a", "b", "c"}
Version
ruff 0.12.12
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation