# Make \_\_replace\_\_ stop interfering with variance inference

**URL:** <https://discuss.python.org/t/make-replace-stop-interfering-with-variance-inference/96092>\
**Category:** Typing\
**Created:** [June 20, 2025, 1:43am UTC](https://discuss.python.org/t/make-replace-stop-interfering-with-variance-inference/96092 "2025-06-20T01:43:54Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![randolf-scholz](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/randolf-scholz/32/11123_2.png) [@randolf-scholz](https://discuss.python.org/u/randolf-scholz)\
**Post date:** [June 20, 2025, 6:29am UTC](https://discuss.python.org/t/make-replace-stop-interfering-with-variance-inference/96092/5 "2025-06-20T06:29:04Z")

</div>

> It makes sense that variables in a NamedTuple and a frozen dataclass should be considered read-only and should therefore not cause a TypeVar to be inferred as invariant.
> 
> Interestingly, Python 3.13’s addition of a ` __replace__ ` method effectively breaks this.

Seems really related to what I was worried about in [Proposal: Optional Explicit covariance/contravariance for PEP 695](https://discuss.python.org/t/proposal-optional-explicit-covariance-contravariance-for-pep-695/35204).

Maybe explicit is better than implicit after all.

---

_[View the full topic](https://discuss.python.org/t/make-replace-stop-interfering-with-variance-inference/96092)._
