Skip to content

Unpacking enum type generates an error #14782

@eltoder

Description

@eltoder

To Reproduce

from enum import Enum

class E(Enum):
    A = 1
    B = 2

A, B = E

Actual Behavior

This code generates an error:

$ mypy --strict proj/iter_enum.py
proj/iter_enum.py:7: error: "Type[E]" object is not iterable  [misc]

Expected Behavior

This should type check without errors. Note that mypy knows that E is actually iterable. For example,

A, B = list(E)

works fine and so does iterating over E in a for loop.

Your Environment

  • Mypy version used: mypy 1.1.0+dev.c23e831ab0e7ec827c38cc830d3ebd3f4c43cd75
  • Mypy command-line flags: with and without --strict
  • Python version used: 3.10.6

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions