Skip to content

Rename dataclass's __replace__ argument from "obj" to "self"? #114198

Closed
@pschanely

Description

@pschanely

Bug report

Bug description:

The first argument of the new __replace__ method on dataclasses is conspicuously named obj rather than self. While that's not a bug, it would be kinder on introspection tools to use self, since it is otherwise a regular instance method.

>>> import dataclasses, inspect, pprint >>> @dataclasses.dataclass ... class Foo: ... x: int ... >>> pprint.pprint({n:inspect.signature(f) for n, f in inspect.getmembers(Foo, inspect.isfunction)}) {'__eq__': <Signature (self, other)>, '__init__': <Signature (self, x: int) -> None>, '__replace__': <Signature (obj, /, **changes)>, '__repr__': <Signature (self)>}

__replace__ was added in #108752

CPython versions tested on:

3.13

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

Labels

easytype-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions