Skip to content

Unexpected '...' in standard tuple #9459

Closed

Description

@frost-nzcr4

Bug Report

To Reproduce

from __future__ import annotations

from typing import Tuple


# Standard tuple
tuple_1: tuple[str, str, str] = ("b", "c", "d")
# error: Unexpected '...'  [misc]
tuple_2_err: tuple[str, ...] = ("b", "c")
# error: Unexpected '...'  [misc]
# error: Dict entry 0 has incompatible type "str": "Tuple[str, str, str]"; expected "str": "Tuple[str, Any]"  [dict-item]
tuple_3_err: tuple[str, ...] = ("b", "c", "d")

dict_with_tuple_1: dict[str, tuple[str, str, str]] = {"a": ("b", "c", "d")}
# error: Unexpected '...'  [misc]
dict_with_tuple_2_err: dict[str, tuple[str, ...]] = {"a": ("b", "c")}
# error: Unexpected '...'  [misc]
# error: Dict entry 0 has incompatible type "str": "Tuple[str, str, str]"; expected "str": "Tuple[str, Any]"  [dict-item]
dict_with_tuple_3_err: dict[str, tuple[str, ...]] = {"a": ("b", "c", "d")}

# typing.Tuple
tuple_10: Tuple[str, str, str] = ("b", "c", "d")
tuple_20: Tuple[str, ...] = ("b", "c")
tuple_30: Tuple[str, ...] = ("b", "c", "d")

dict_with_tuple_10: dict[str, Tuple[str, str, str]] = {"a": ("b", "c", "d")}
dict_with_tuple_20: dict[str, Tuple[str, ...]] = {"a": ("b", "c")}
dict_with_tuple_30: dict[str, Tuple[str, ...]] = {"a": ("b", "c", "d")}

Expected Behavior

I've expected that tuple and typing.Tuple works the same and errors will not occurs.

Actual Behavior

Standard tuple have got error: Unexpected '...' [misc]

Your Environment

  • Mypy version used: 0.790+dev.44a96876c9f2303af8258532f99cd821a98112dc
  • Mypy command-line flags: --ignore-missing-imports --show-error-codes
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: Python 3.9.0rc2
  • Operating system and version: docker FROM python:3.9-rc-buster

Activity

  1. hauntsaninja commented on Sep 18, 2020

    @hauntsaninja
    Collaborator

    Dupe of #7907

  2. Jasha10 commented on Nov 8, 2021

    @Jasha10

    The linked issue #7907 reports that this issue was solved by PR #9564, but I find that this is still an issue in mypy version 0.910:

    from typing import Tuple
    ex1: Tuple[int, ...]  # ok
    ex2 = Tuple[int, ...]  # ok
    ex3: tuple[int, ...]  # ok
    ex4 = tuple[int, ...]  # error: Unexpected "..."

    Should we reopen this issue? Or should I file a new one?

  3. hauntsaninja commented on Nov 8, 2021

    @hauntsaninja
    Collaborator

    This has been fixed on master for a long time, try pip install -U git+git://github.com/python/mypy.git.

    This issue tracks the 0.920 release: #11158
    Unfortunately, the people with the ability to push the release over the line have been really busy.

  4. ShahriyarR commented on Nov 24, 2021

    @ShahriyarR

    Same issue with Callable[[], ...] the result error: Unexpected "..."

    $ mypy --version
    mypy 0.920+dev.b47245adc60eecde9164799c426f3bffcedbc48e
    
    $ python3 --version
    Python 3.9.6
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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