from typing_extensions import TypedDict, NotRequired, ReadOnly
class A(TypedDict, extra_items=float):
x: float
y: float
class B(A):
z: ReadOnly[NotRequired[float]]
def f(a: A) -> None:
a["z"] = 0
b: B = {"x": 1, "y": 2, "z": 3}
f(b)
pyright playground version
Class A has mutable extra_items, while its subclass B adds a new read-only field. However, this field can be mutated by functions that accept type A, which violates the ReadOnly constraint. Why do pyright allow this?