Skip to content

1.7.0 Regression? No overload variant of "__or__" of "dict" matches argument type "Mapping[str, Any]" #16489

Closed as not planned
@randolf-scholz

Description

@randolf-scholz

Bug Report

This raises no issues in 1.6.1, but does in 1.7

To Reproduce

https://mypy-play.net/?mypy=1.7.0&python=3.11&gist=8ba136e1df27dd669f8a881052b6a3b4

from collections.abc import Mapping
from typing import Any


def make_plot(subplot_kwargs: Mapping[str, Any]) -> None:
    subplot_kwargs = {  # raises [operator]
        "option1": "default1",
        "option2": "default2",
    } | subplot_kwargs
    # plotfn(..., **subplot_kwargs)
main.py:6: error: No overload variant of "__or__" of "dict" matches argument type "Mapping[str, Any]"  [operator]
main.py:6: note: Possible overload variants:
main.py:6: note:     def __or__(self, dict[str, str], /) -> dict[str, str]
main.py:6: note:     def [_T1, _T2] __or__(self, dict[_T1, _T2], /) -> dict[str | _T1, str | _T2]

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