ty
ty copied to clipboard
Support dict literals and `dict()` calls as default values for parameters annotated with `TypedDict` types
Summary
Originally reported by @mflova in https://github.com/astral-sh/ty/issues/2127#issuecomment-3678156698. We should be able to use the type context of the parameter annotation to avoid emitting a diagnostic on either of these:
from typing import TypedDict
class Foo(TypedDict):
x: int
def x(a: Foo = {"x": 42}): ...
def y(a: Foo = dict(x=42)): ...
Version
No response