Thank you for your efforts! I'm glad to see this promising attempt to allow using TypedDict for **kwargs precise typing. It is amazing, I have seen many use cases for that, often to make stub code more DRY and close to the original implementation (requests, where get, post, etc. share signature [1], django-stubs with model fields - more than 10 arguments with non-trivial signatures [2]).
I have a question regarding point 3 in the "assignment" chapter. Why should this be considered safe? mypy rejects the following code:
def foo(*, title: str, year: int = ...) -> int: # same as **kwargs: **Movie
...
def bar(title: str, year: int = ...) -> int:
...
bar = foo # E: Incompatible types in assignment (expression has type "Callable[[NamedArg(str, 'title'), DefaultNamedArg(int, 'year')], int]", variable has type "Callable[[str, int], int]")
The reason is that foo('a', 0) was allowed before assignment and fails after it (positional-or-keyword parameters should not be substituted with keyword-only). So why should essentially the same code be allowed with TypedDict?