]> granicus.if.org Git - python/commitdiff
Add 'Field' to dataclasses.__all__. (GH-6182)
authorEric V. Smith <ericvsmith@users.noreply.github.com>
Wed, 21 Mar 2018 21:10:22 +0000 (17:10 -0400)
committerGitHub <noreply@github.com>
Wed, 21 Mar 2018 21:10:22 +0000 (17:10 -0400)
- Add missing 'Field' to __all__.
- Improve tests to catch this.

Lib/dataclasses.py
Lib/test/test_dataclasses.py
Misc/NEWS.d/next/Library/2018-03-21-16-52-26.bpo-33116.Tvzerj.rst [new file with mode: 0644]

index d61643249148899bdc1fb1330a1566910192f46e..41b5b5da325c2b095b1dd6b22a82540bf93022b4 100644 (file)
@@ -5,6 +5,7 @@ import inspect
 
 __all__ = ['dataclass',
            'field',
+           'Field',
            'FrozenInstanceError',
            'InitVar',
            'MISSING',
@@ -513,7 +514,7 @@ def _get_field(cls, a_name, a_type):
     #  and InitVars are also returned, but marked as such (see
     #  f._field_type).
 
-    # If the default value isn't derived from field, then it's
+    # If the default value isn't derived from Field, then it's
     #  only a normal default value.  Convert it to a Field().
     default = getattr(cls, a_name, MISSING)
     if isinstance(default, Field):
index 9b5aad25745f7ff2d83f2854b9e21dc90fcfb60b..69ace36c2c58d647d417f8340de56f1b09d482ce 100755 (executable)
@@ -1,7 +1,8 @@
-from dataclasses import (
-    dataclass, field, FrozenInstanceError, fields, asdict, astuple,
-    make_dataclass, replace, InitVar, Field, MISSING, is_dataclass,
-)
+# Deliberately use "from dataclasses import *".  Every name in __all__
+# is tested, so they all must be present.  This is a way to catch
+# missing ones.
+
+from dataclasses import *
 
 import pickle
 import inspect
diff --git a/Misc/NEWS.d/next/Library/2018-03-21-16-52-26.bpo-33116.Tvzerj.rst b/Misc/NEWS.d/next/Library/2018-03-21-16-52-26.bpo-33116.Tvzerj.rst
new file mode 100644 (file)
index 0000000..90072d8
--- /dev/null
@@ -0,0 +1 @@
+Add 'Field' to dataclasses.__all__.