You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mypy doesn't catch unhashable literals in hashdependant literals. #8150
Mypy reports this as fine with no errors.
It should detect and throw when encountering {{1}: 0} or Dict[Set[int], int] or {{1}} or {[1]} since these are literals whose types are not hashable therefore they may not be used in types that require members be hashable i.e. Dict or Set.
I'm using mypy 0.750 and Python 3.8.0 (default, Oct 23 2019, 18:51:26) [GCC 9.2.0] on linux
If needed I'm happy to attempt to PR this myself :)
This is basically a duplicate of #2455, although the example in this issue is a bit more foundational.
The reason why this has been open for so long is that the hashability protocol in Python behaves a bit weirdly: all objects are hashable by default, except that certain objects explicitly mark themselves as not hashable. Catching this sort of thing in mypy probably requires some special casing.
Activity
JelleZijlstra commentedon Dec 16, 2019
This is basically a duplicate of #2455, although the example in this issue is a bit more foundational.
The reason why this has been open for so long is that the hashability protocol in Python behaves a bit weirdly: all objects are hashable by default, except that certain objects explicitly mark themselves as not hashable. Catching this sort of thing in mypy probably requires some special casing.
ilevkivskyi commentedon Dec 18, 2019
Yeah, I think this is a dupe.