__replace__ was added onto NamedTuple as a part of 3.13 related changes, however, instead of returning None, it should return Self. Looking in cpython we can see this is the case.
Furthermore, this is important for compatibility with copy.replace. In python/typeshed#12262 we're adding a protocol that requires replaceable objects implement:
class _SupportsReplace(Protocol):
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
With namedtuple.__replace__ returning None, users will return into false positives here, when in reality it should work just fine.
__replace__was added ontoNamedTupleas a part of 3.13 related changes, however, instead of returningNone, it should returnSelf. Looking in cpython we can see this is the case.Furthermore, this is important for compatibility with
copy.replace. In python/typeshed#12262 we're adding a protocol that requires replaceable objects implement:With
namedtuple.__replace__returningNone, users will return into false positives here, when in reality it should work just fine.