Hey, based on developer feedback I wanted to propose changes to PEP 692. Here is a link to the PR with proposed changes.
In a nutshell, from type checkers point of view, the function signature typed with Unpack
should be equivalent to its explicitly expanded form. Therefore:
class Movie(TypedDict):
name: str
year: int
def foo(**kwargs: Unpack[Movie]): ...
should be equivalent to:
def foo(*, name: str, year: int): ...
This creates a more robust specification for the feature. Alsot it is a lot simpler to remember and reason about and should not jeopardize type safety. Ivan’s comment goes into a bit more depth on the issue.
Also, when it comes to the Passing kwargs inside a function to another function from section - we cannot expect type checkers to treat the same function call differently depending on the context, therefore this feature should be deleted from the specification. This, however, should not degrade the value of the rest of the proposal.
Let me know what you think!