Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLR6201 autofix is unsafe without type information #8096

Closed
Avasam opened this issue Oct 20, 2023 · 0 comments · Fixed by #8097
Closed

PLR6201 autofix is unsafe without type information #8096

Avasam opened this issue Oct 20, 2023 · 0 comments · Fixed by #8097

Comments

@Avasam
Copy link

Avasam commented Oct 20, 2023

Non-hashable entries should not be put in a set.
See the following minimal reproduction:

dict1 = {"foo": 1}
dict2 = {"foo": 2}
dicttest = {"foo": 3}
print(dicttest in (dict1, dict2))

It gets autofix to:

dict1 = {"foo": 1}
dict2 = {"foo": 2}
dicttest = {"foo": 3}
print(dicttest in {dict1, dict2})

which results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'dict'

and pyright only reports as error: Set entry must be hashable since https://github.com/microsoft/pyright/releases/tag/1.1.323

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant