]> granicus.if.org Git - python/commitdiff
bpo-33494: Change dataclasses.Fields repr to use the repr of each of its members...
authorEric V. Smith <ericvsmith@users.noreply.github.com>
Mon, 14 May 2018 15:37:28 +0000 (11:37 -0400)
committerGitHub <noreply@github.com>
Mon, 14 May 2018 15:37:28 +0000 (11:37 -0400)
Lib/dataclasses.py
Misc/NEWS.d/next/Library/2018-05-14-10-29-03.bpo-33495.TeGTQJ.rst [new file with mode: 0644]

index 04e07f8cf8c2703f93909dec5ff47bba0fedfa85..c60eeaa58368382bc3dd1a3da2b2e975195944d5 100644 (file)
@@ -230,14 +230,14 @@ class Field:
     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 (file)
index 0000000..22cf04c
--- /dev/null
@@ -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.