Skip to content

bpo-33495: Change dataclasses.Fields repr to use the repr of member #6798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ def __init__(self, default, default_factory, init, repr, hash, compare,
def __repr__(self):
return ('Field('
f'name={self.name!r},'
f'type={self.type},'
f'default={self.default},'
f'default_factory={self.default_factory},'
f'init={self.init},'
f'repr={self.repr},'
f'hash={self.hash},'
f'compare={self.compare},'
f'metadata={self.metadata}'
f'type={self.type!r},'
f'default={self.default!r},'
f'default_factory={self.default_factory!r},'
f'init={self.init!r},'
f'repr={self.repr!r},'
f'hash={self.hash!r},'
f'compare={self.compare!r},'
f'metadata={self.metadata!r}'
')')

# This is used to support the PEP 487 __set_name__ protocol in the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Change dataclasses.Fields repr to use the repr of each of its members,
instead of str. This makes it more clear what each field actually
represents. This is especially true for the 'type' member.