Skip to content

Commit 2473eea

Browse files
authored
bpo-33494: Change dataclasses.Fields repr to use the repr of each of its members (GH-6798)
1 parent 7ffd4c5 commit 2473eea

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Lib/dataclasses.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ def __init__(self, default, default_factory, init, repr, hash, compare,
230230
def __repr__(self):
231231
return ('Field('
232232
f'name={self.name!r},'
233-
f'type={self.type},'
234-
f'default={self.default},'
235-
f'default_factory={self.default_factory},'
236-
f'init={self.init},'
237-
f'repr={self.repr},'
238-
f'hash={self.hash},'
239-
f'compare={self.compare},'
240-
f'metadata={self.metadata}'
233+
f'type={self.type!r},'
234+
f'default={self.default!r},'
235+
f'default_factory={self.default_factory!r},'
236+
f'init={self.init!r},'
237+
f'repr={self.repr!r},'
238+
f'hash={self.hash!r},'
239+
f'compare={self.compare!r},'
240+
f'metadata={self.metadata!r}'
241241
')')
242242

243243
# This is used to support the PEP 487 __set_name__ protocol in the
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Change dataclasses.Fields repr to use the repr of each of its members,
2+
instead of str. This makes it more clear what each field actually
3+
represents. This is especially true for the 'type' member.

0 commit comments

Comments
 (0)