[Python-checkins] bpo-33494: Change dataclasses.Fields repr to use the repr of each of its members (GH-6798)
Miss Islington (bot)
webhook-mailer at python.org
Mon May 14 13:31:13 EDT 2018
https://github.com/python/cpython/commit/ceb45f0df87071319e6f73fb03e663ac39917daf
commit: ceb45f0df87071319e6f73fb03e663ac39917daf
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-05-14T10:31:10-07:00
summary:
bpo-33494: Change dataclasses.Fields repr to use the repr of each of its members (GH-6798)
(cherry picked from commit 2473eea65d592a80a5362a00362738a33196aba1)
Co-authored-by: Eric V. Smith <ericvsmith at users.noreply.github.com>
files:
A Misc/NEWS.d/next/Library/2018-05-14-10-29-03.bpo-33495.TeGTQJ.rst
M Lib/dataclasses.py
diff --git a/Lib/dataclasses.py b/Lib/dataclasses.py
index 04e07f8cf8c2..c60eeaa58368 100644
--- a/Lib/dataclasses.py
+++ b/Lib/dataclasses.py
@@ -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
diff --git a/Misc/NEWS.d/next/Library/2018-05-14-10-29-03.bpo-33495.TeGTQJ.rst b/Misc/NEWS.d/next/Library/2018-05-14-10-29-03.bpo-33495.TeGTQJ.rst
new file mode 100644
index 000000000000..22cf04cd2e43
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2018-05-14-10-29-03.bpo-33495.TeGTQJ.rst
@@ -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.
More information about the Python-checkins
mailing list