-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
astral-sh/ruff
#22294Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typetypeddict
Milestone
Description
We currently only consider the type context if there is a single TypedDict element. We should support the following:
from typing import TypedDict
class Foo(TypedDict):
foo: int
class Bar(TypedDict):
bar: int
x: Foo | Bar = reveal_type({ "foo": 1 }) # Foo
class FooBar1(TypedDict):
foo: int
bar: int
class FooBar2(TypedDict):
foo: int
bar: int
x: FooBar1 | FooBar2 = reveal_type({ "foo": 1, "bar": 1 }) # FooBar1 | FooBar2Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bidirectional inferenceInference of types that takes into account the context of a declared type or expected typeInference of types that takes into account the context of a declared type or expected typetypeddict