Skip to content

Support subtyping Literal with StrEnum and IntEnum values #19243

Closed as not planned
@randolf-scholz

Description

@randolf-scholz

Feature

The following (mypy playground) should pass, i.e. recognize StrEnum values as subtypes of the corresponding Literal.

from enum import StrEnum
from typing import Literal

class Options(StrEnum):
    X = "X"
    Y = "Y"
    
x: Literal["X"] = Options.X  # mypy: incompatible types in assignment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions