Skip to content

detect invalid Literal[Foo.foo | Foo.bar]Literal[Foo.foo, Foo.bar] #20438

@spaceone

Description

@spaceone
import enum
from typing import Literal


class Foo(enum.IntEnum):
    foo = 1
    bar = 2


def foo(bar: Literal[Foo.foo | Foo.bar]) -> None:
    pass

ty detect this as invalid-type-form:

$ ty check t.py 
t.py:10:22: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member

(astral-sh/ty#876 (comment))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions