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

Type application has too many types for literal union with tuple #12679

Closed
antonagestam opened this issue Apr 27, 2022 · 1 comment
Closed

Type application has too many types for literal union with tuple #12679

antonagestam opened this issue Apr 27, 2022 · 1 comment
Labels
bug mypy got something wrong topic-pep-604 PEP 604 (union | operator)

Comments

@antonagestam
Copy link
Contributor

Bug Report

False positive for type application of builtin tuple when using pipe-syntax unions.

To Reproduce

Type check this code (mypy playground):

from fractions import Fraction
from typing import Union

A = tuple[int, int] | Fraction
B = Union[tuple[int, int], Fraction]

Expected Behavior

A should be inferred identically as B, with no errors.

Actual Behavior

mypy claims tuple receives too many type arguments.

repro-too-many-types.py:5: error: Type application has too many types (1 expected)  [misc]
    A = tuple[int, int] | Fraction
        ^
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.942 and master@cb6581a
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10.1
  • Operating system and version: Macos 12.3
@antonagestam antonagestam added the bug mypy got something wrong label Apr 27, 2022
@JelleZijlstra JelleZijlstra added the topic-pep-604 PEP 604 (union | operator) label Apr 27, 2022
@JelleZijlstra
Copy link
Member

Duplicate of #11098

@JelleZijlstra JelleZijlstra marked this as a duplicate of #11098 Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-604 PEP 604 (union | operator)
Projects
None yet
Development

No branches or pull requests

2 participants