Thanks to visit codestin.com
Credit goes to github.com

Skip to content

new union syntax doesn't work on Literals #11426

Closed
@DetachHead

Description

@DetachHead
from __future__ import annotations

from typing import Literal

Foo = Literal[1, 2]

Bar = Foo | Literal[3] # error: Unsupported left operand type for | ("object")

https://mypy-play.net/?mypy=latest&python=3.10&gist=3a429dfa3e9e3b692aac25887027ab69

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-604PEP 604 (union | operator)topic-type-aliasTypeAlias and other type alias issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions