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

[question] dictionary _KT typevar and hashability #3884

Closed
BvB93 opened this issue Mar 27, 2020 · 3 comments
Closed

[question] dictionary _KT typevar and hashability #3884

BvB93 opened this issue Mar 27, 2020 · 3 comments

Comments

@BvB93
Copy link
Contributor

BvB93 commented Mar 27, 2020

Dear all,

I recently noticed that the _KT typevar used in annotating dict has no upper bound specified, yet dictionary keys must (as far as I'm aware) always be hashable.

Is there a reason here as to why _KT is not defined as TypeVar('_KT', bound=Hashable)?

Regards, Bas

@JelleZijlstra
Copy link
Member

The Hashable type can't really be typechecked (because all types are hashable by default); see prior discussion in #2148, python/mypy#1746, python/mypy#2455.

@BvB93
Copy link
Contributor Author

BvB93 commented Apr 4, 2020

Thanks for the info!
I'd consider this question answered.

@ikonst
Copy link
Contributor

ikonst commented Apr 26, 2020

Given that certain types are marked as non-hashable (#3219) wouldn't this have at least a fringe value?

MaxG87 added a commit to MaxG87/collectiondict that referenced this issue Mar 20, 2024
It would be best if `mypy` would directly reject unhashable types, but
according to python/typeshed#3884 this is
unfeasible. Therefore, a small tests is added to serve as marker and
playground.
MaxG87 added a commit to MaxG87/collectiondict that referenced this issue Mar 20, 2024
It would be best if `mypy` would directly reject unhashable types, but
according to python/typeshed#3884 this is
unfeasible. Therefore, a small tests is added to serve as marker and
playground.
MaxG87 added a commit to MaxG87/collectiondict that referenced this issue Mar 20, 2024
It would be best if `mypy` would directly reject unhashable types, but
according to python/typeshed#3884 this is
unfeasible. Therefore, a small tests is added to serve as marker and
playground.
MaxG87 added a commit to MaxG87/collectiondict that referenced this issue Mar 20, 2024
It would be best if `mypy` would directly reject unhashable types, but
according to python/typeshed#3884 this is
unfeasible. Therefore, a small tests is added to serve as marker and
playground.
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

No branches or pull requests

3 participants