Skip to content

Star operator gets confused when the type has multiple generics #11138

Closed
@KotlinIsland

Description

@KotlinIsland

Bug Report
When a type has multiple generics and is an iterable, the star operator results in the wrong type

from typing import Iterator, Generic, TypeVar
T = TypeVar("T")
T2 = TypeVar("T2")

class A(Iterator[T2], Generic[T, T2]):
    ...
a: A[int, Iterator[int]]
reveal_type((*a,))
b: list[list[int]] = [*a]

To Reproduce

(Write your steps here:)

  1. Step 1...
  2. Step 2...
  3. Step 3...

Expected Behavior

(Write what you thought would happen.)

Actual Behavior

(Write what happened.)

Your Environment

  • Mypy version used: 0.910
  • Mypy command-line flags: na
  • Mypy configuration options from mypy.ini (and other config files): na
  • Python version used: 3.10
  • Operating system and version: mypy playground

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