Skip to content

str not detected as Hashable #8293

Closed
Closed
@corynezin

Description

@corynezin

This is probably a duplicate of #1746 - but I don't see a resolution

  • Are you reporting a bug, or opening a feature request?
  • Not sure if it's a bug or intended
  • Please insert below the code you are checking with mypy,
    or a mock-up repro if the source is private. We would appreciate
    if you try to simplify your case to a minimal repro.
from typing import Hashable, Dict

def foo(d: Dict[Hashable, int]):
  ...

d: Dict[str, int] = {'a': 1}
foo(d)
  • What is the actual behavior/output?
    test.py:7: error: Argument 1 to "foo" has incompatible type "Dict[str, int]"; expected "Dict[Hashable, int]"
  • What is the behavior/output you expect?
    Success: no issues found in 1 source file
  • What are the versions of mypy and Python you are using?
    Do you see the same issue after installing mypy from Git master?
    mypy 0.761
  • What are the mypy flags you are using? (For example --strict-optional)
    None
  • If mypy crashed with a traceback, please paste
    the full traceback below.

(You can freely edit this text, please remove all the lines
you believe are unnecessary.)

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