Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
randolf-scholz opened this issue Nov 14, 2023 · 1 comment
Labels
bug mypy got something wrong

Comments

@randolf-scholz
Copy link
Contributor

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]
@randolf-scholz randolf-scholz added the bug mypy got something wrong label Nov 14, 2023
@JelleZijlstra
Copy link
Member

This is python/typeshed#10679 and the error is correct: dict.__or__ doesn't accept arbitrary Mappings.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants