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

Possible regression: a niche case in expression type detection #11836

Open
neutrinoceros opened this issue Dec 23, 2021 · 0 comments
Open

Possible regression: a niche case in expression type detection #11836

neutrinoceros opened this issue Dec 23, 2021 · 0 comments
Labels
bug mypy got something wrong

Comments

@neutrinoceros
Copy link

Bug Report

After upgrading mypy to 0.930 I'm finding new confusing errors that I think are incorrect (false positives)

To Reproduce

This example may not be strictly minimal, but it's close to the real case example where I discovered the new error, while still being much more concise.

# t.py
from typing import Tuple, List

ElementT = Tuple[str, Tuple[str, List[str]]]
ContainerT = Tuple[ElementT, ...]

a: ContainerT = tuple((f1, (f2, [])) for f1, f2 in (("", ""), ("", "")))

b: ContainerT = (("", ("", [])),)

# The following four lines should be equally valid (or invalid) regarding types
# but only the last one raises an error
c1: ContainerT = a + b  # works fine !
c2: ContainerT = b + a  # this too !
c3: ContainerT = a + (("", ("", [])),)  # also works
c4: ContainerT = (("", ("", [])),) + a  # but this doesn't
$ mypy t.py
t_typ.py:16: error: Incompatible types in assignment (expression has type "Tuple[Union[Tuple[str, Tuple[str, List[<nothing>]]], Tuple[str, Tuple[str, List[str]]]], ...]", variable has type "Tuple[Tuple[str, Tuple[str, List[str]]], ...]")
Found 1 error in 1 file (checked 1 source file)

Expected Behavior

No error (this example type-checks with mypy 0.910)

Your Environment

  • Mypy version used: 0.910 and 0.930
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10
  • Operating system and version: MacOS 12.0.1
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

1 participant