Closed
Description
ReadOnly was implemented in #17644. I think the implementation is incomplete -- this generates a false positive:
from typing import TypedDict
from typing_extensions import ReadOnly
class A(TypedDict):
name: ReadOnly[str | None]
class B(TypedDict):
name: str
def f(a: A) -> None: ...
b: B = {"name": "x"}
f(b) # Incompatible type "B"; expected "A"
Extract from PEP 705:
Read-only items behave covariantly, as they cannot be mutated.
cc @sobolevn