Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed
Assignees
ericvsmith
Labels
easytype-featureA feature request or enhancement
@pschanely

Description

@pschanely

Bug report

Bug description:

The first argument of the new__replace__ method on dataclasses is conspicuously namedobj rather thanself. While that's not a bug, it would be kinder on introspection tools to useself, since it is otherwise a regular instance method.

>>>importdataclasses,inspect,pprint>>>@dataclasses.dataclass...classFoo:...x:int...>>>pprint.pprint({n:inspect.signature(f)forn,fininspect.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


    [8]ページ先頭

    ©2009-2025 Movatter.jp