Skip to content
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

REGR: 0.981 dict-item error for union of Iterable and Mapping #13750

Closed
twoertwein opened this issue Sep 28, 2022 · 1 comment
Closed

REGR: 0.981 dict-item error for union of Iterable and Mapping #13750

twoertwein opened this issue Sep 28, 2022 · 1 comment
Labels
bug mypy got something wrong

Comments

@twoertwein
Copy link

Bug Report

from __future__ import annotations

from typing import (
    Any,
    Hashable,
    Iterable,
    Iterator,
    Mapping,
    TypeVar,
)

HashableT = TypeVar("HashableT", bound=Hashable)


class Series:
    ...


def concat(objs: Iterable[Series] | Mapping[HashableT, Series]) -> Series:
    ...


def concat_single(objs: Mapping[HashableT, Series]) -> Series:
    ...


def concat_iterator(objs: Iterator[Series] | Mapping[HashableT, Series]) -> Series:
    ...


def concat_any(objs: Iterable[Series] | Mapping[Any, Series]) -> Series:
    ...


s1 = Series()
s2 = Series()

concat({1: s1, None: s2})  # fails
concat_single({1: s1, None: s2})  # works
concat_iterator({1: s1, None: s2})  # works
concat_any({1: s1, None: s2})  # works

Expected Behavior

No error :)

Actual Behavior

test.py:38: error: Dict entry 0 has incompatible type "int": "Series"; expected "Series": "Series" [dict-item]
test.py:38: error: Dict entry 1 has incompatible type "None": "Series"; expected "Series": "Series" [dict-item]

Your Environment

  • Mypy version used: 0.981
  • Python version used: 3.10.4
@twoertwein twoertwein added the bug mypy got something wrong label Sep 28, 2022
@hauntsaninja
Copy link
Collaborator

Thanks, this is fixed on master.

mypy_primer -p ~/dev/mypy_primer/test.py --bisect --new v0.981 --old v0.971 --debug bisected it to #13303, which had some issues that were fixed in #13461

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