Skip to content

Support calls to enum classes #7027

@erictraut

Description

@erictraut

When an enum class is created, the EnumType metaclass replaces its original constructor with a new implementation that performs a value-based lookup. The following should therefore type check without errors.

from enum import Enum

class Example(Enum):
    A = (1, 2)

    def __init__(self, value, other) -> None:
        self._value_ = value
        self.other = other

Example(1)  # This should not generate an error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions