KEMBAR78
Regression on master: dict.get(default=None) gives 'no overload matches argument types' · Issue #11646 · python/mypy · GitHub
Skip to content

Regression on master: dict.get(default=None) gives 'no overload matches argument types' #11646

@intgr

Description

@intgr

Bug Report

After the latest sync from typeshed (commit 4996d57, PR #11600), this valid code is highlighted as error by mypy:

def foo(vars: dict[str, str]):
    val = vars.get("fqdn", default=None)
    reveal_type(val)

Result before:

_local/dictget.py:3: note: Revealed type is "Union[builtins.str, None]"

Result after:

_local/dictget.py:2: error: No overload variant of "get" of "Mapping" matches argument types "str", "None"
_local/dictget.py:2: note: Possible overload variants:
_local/dictget.py:2: note:     def get(self, key: str) -> Optional[str]
_local/dictget.py:2: note:     def [_T] get(self, str, Union[str, _T]) -> Union[str, _T]
_local/dictget.py:3: note: Revealed type is "Any"

Your Environment

  • Mypy version used: mypy 0.920+dev.4996d571272adde83a3de2689c0147ca1be23f2c
  • Mypy command-line flags: (none)
  • Mypy configuration options from mypy.ini (and other config files): (none)
  • Python version used: 3.10.0
  • Operating system and version: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions