Skip to content

[question] dictionary _KT typevar and hashability #3884

Closed

Description

@BvB93

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

Activity

  1. JelleZijlstra commented on Mar 28, 2020

    @JelleZijlstra
    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.

  2. BvB93 commented on Apr 4, 2020

    @BvB93
    ContributorAuthor

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

  3. ikonst commented on Apr 26, 2020

    @ikonst
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions