[ty] Error when duplicate keywords are provided to TypedDict constructors by charliermarsh · Pull Request #24449 · astral-sh/ruff (original) (raw)

Summary

E.g., in the following, we should validate that the argument is repeated, since this fails at runtime:

from typing import TypedDict

class DuplicateHasName(TypedDict): name: str

class DuplicateNeedsName(TypedDict): name: str

def duplicate_name_keys( left: DuplicateHasName, right: DuplicateHasName, ) -> None: # error: [parameter-already-assigned] DuplicateNeedsName(**left, name="x")

# error: [parameter-already-assigned]
DuplicateNeedsName(**left, **right)