ty icon indicating copy to clipboard operation
ty copied to clipboard

Support dict literals and `dict()` calls as default values for parameters annotated with `TypedDict` types

Open AlexWaygood opened this issue 6 days ago • 0 comments

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

AlexWaygood avatar Dec 22 '25 15:12 AlexWaygood