Hi there,

It's fairly common within our code bases to define throwaway dicts for adding logging context or generating keyword arguments dynamically, e.g.:

kwargs = {}
if foo:
    kwargs["something"] = foo
if bar:
    kwargs["another_thing"] = [1, 2, 3]
cool_function(**kwargs)

Defining TypedDict subclasses for these throwaway dicts can be tiresome, so these often get annotated with dict[str, Any], which opens a door for errors that a type checker would catch if we did define TypedDicts for them.

I've been following the progress of PEPs 637 & 655 and had a thought this morning that they could be combined to generate a not-horrifically-ugly way to define TypedDicts inline. For the example above:

kwargs: TypedDict[something=Required[str], another_thing=NotRequired[list[int]]] = {}
if foo:
    ...

Is it worth pursuing this thought further, or are there blockers on this that I'm oblivious to?

Cheers,

Andrew