-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
astral-sh/ruff
#20875Labels
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 type
Description
This snippet currently type-checks:
from typing import TypedDict, overload, reveal_type
class T(TypedDict):
x: int
def f(x: T): ...
x: T | int = { "y": 1 }
reveal_type(x)Bi-directional type-inference doesn't see through the union, so we infer dict[Unknown | str, Unknown | int]. We also don't end up validating the TypedDict constructor.
Reactions 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 type