Skip to content

autocomplete for discriminated unions #1442

Description

@zojize

Use Cases

from typing import TypedDict, Literal, TypeAlias

class Foo(TypedDict):
    kind: Literal["foo"]
    foo_value: int

class Bar(TypedDict):
    kind: Literal["bar"]
    bar_value: str

type FooBar = Foo | Bar

case 1

item: FooBar = {
    "kind": "|",
}

expected completion: 'foo' | 'bar'

case 2

item: FooBar = {
    "kind": "foo",
    "|"
}

expected completion: 'foo_value'

Metadata

Metadata

Labels

language-serverIssues specific to our IDE integration rather than type checkingtypechecking

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions