fix: Make map.Map and maptree.MapTree require keys to be hashable - #258
Conversation
|
Parent: python/typeshed#15754 |
dbrattli
left a comment
There was a problem hiding this comment.
Thanks for the typeshed-alignment proposal. Before this can be reviewed for merge, please rebase onto the current main (the branch is nine commits behind) and add focused type-check coverage demonstrating that comparable-but-unhashable keys are rejected while standard ordered, hashable keys remain accepted. Please also simplify the new protocol implementation to a declaration-only member (...) rather than calling super().__hash__(); the protocol is structural and has no meaningful runtime implementation.
dbrattli
left a comment
There was a problem hiding this comment.
Approved. The hashable key bound correctly aligns Map with the Mapping contract and its existing use of key hashing. My previous request reflected integration preferences rather than a design blocker; a maintainer update/rebase can be handled as part of merge preparation.
map.Map and maptree.MapTree require keys to be hashablemap.Map and maptree.MapTree require keys to be hashable
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Fixed the strict Pyright failures in |
Seeing as though the
map.Mapclass implements theMappinginterface, the type variable used to annotate its keys should require hashability, and the same goes formaptree.MapTree, used internally by the above only.