Skip to content

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

Closed
@akeeman

Description

@akeeman

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

  • Mypy version used: 0.812
  • Mypy command-line flags: test.py
  • Mypy configuration options from mypy.ini (and other config files): <none>
  • Python version used: 3.8.9
  • Operating system and version: Debian 10 (buster) (docker run --rm -i -t --entrypoint bash python:3.8.9)

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