Skip to content

mypy rejects unpacking into same variable #14786

Open
@PeterJCLaw

Description

@PeterJCLaw

Bug Report

I believe the following code should be fine, however mypy rejects the case where we're unpacking into the variable which was expanded:

foo: tuple[int, ...] = ()

# Ok
bar, *quox = foo

# Incompatible types in assignment (expression has type "List[int]", variable has type "Tuple[int, ...]")  [assignment]
bar, *foo = foo

There are a number of similar issues reported, the closest being #9706, however I believe this is distinct as it reproduces when the generic type is int (though my original code was using str). This suggests a different root cause.

Your Environment

  • Mypy version used: 1.0.1
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions