python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.37k stars 2.82k forks source link

({},) is incompatible with Iterable[Mapping[str, Any]] #10319

Closed akeeman closed 1 year ago

akeeman commented 3 years ago

Bug Report

({},) is incompatible with Iterable[Mapping[str, Any]] / Iterable[Dict[str, Any]]

To Reproduce

Have a file like this (test.py):

from typing import Any, Iterable, Mapping

def foo(foo: Iterable[Mapping[str, Any]]) -> None:
    pass

foo(({},))

then, run mypy test.py

Expected Behavior

Expected to succeed:

Success: no issues found in 1 source file

Actual Behavior

Got an error:

test.py:8: error: Argument 1 to "foo" has incompatible type "Tuple[Dict[<nothing>, <nothing>]]"; expected "Iterable[Mapping[str, Any]]"
Found 1 error in 1 file (checked 1 source file)

Using more specific Iterables, like List or Tuple, does not result in an error (as expected).

Your Environment

erictraut commented 1 year ago

This bug appears to have been fixed. It doesn't occur with the latest version of mypy (1.5).

hauntsaninja commented 1 year ago

Fixed in #13406