typeshed PR python/typeshed#14786 (synced into mypy) changed copy.replace from a bound-TypeVar signature to a covariant protocol. This breaks copy.replace for __replace__ methods that return Self (dataclasses, namedtuples, etc.) when the argument is a bounded TypeVar.
The bound-TypeVar approach preserved the argument type; the covariant protocol loses it because _RT_co is inferred from the protocol method return type which, for Self, resolves at the upper bound level.
Note
The motivation for python/typeshed#14786 was mypy issue #19694 which is about dataclasses.replace (not copy.replace), so the PR did not actually address its intended target.
changed the title [-]copy.replace type inference regression: breaks Self-returning __replace__ with bound TypeVar[/-][+]`copy.replace` type inference regression: breaks Self-returning __replace__ with bound TypeVar[/+]on Jul 3, 2026
Activity
trim21 commented on Aug 9, 2026
relative: python/typeshed#15973 python/typeshed#15997
test: Seeded keeps its own __post_init__ beside SeededByDefault's (#354)