PLR6201 fails but cannot be fixed on list in tuple(list, list)
#9928
Labels
bug
Something isn't working
list in tuple(list, list)
#9928
Thanks for developing and supporting this wonderful tool! I'm using ruff 0.2.0. Say I have a bit of code to check if some list appears in a predefined collection of lists:
Running
ruff . --preview
fails with "PLR6201 Use aset
literal when testing for membership"... which you certainly should do whenever you can, but you cannot in this case. Python lists are not hashable, so you cannot insert them into a set. If you try, likereturn x in {list1, list2}
, you get "TypeError: unhashable type: 'list'".PLR6201 should not fail in this case because it is unfixable. Instead, PLR6201 should only fail if the items in the membership test are hashable.
The text was updated successfully, but these errors were encountered: