bpo-33116: Add 'Field' to dataclasses.all. (GH-6182) (GH-6183) · python/cpython@4ddc99d (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 4ddc99d

miss-islingtonericvsmith

and

committed

- Add missing 'Field' to __all__. - Improve tests to catch this. (cherry picked from commit 8e4560a) Co-authored-by: Eric V. Smith ericvsmith@users.noreply.github.com

File tree

3 files changed

lines changed

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
5 5
6 6 __all__ = ['dataclass',
7 7 'field',
8 +'Field',
8 9 'FrozenInstanceError',
9 10 'InitVar',
10 11 'MISSING',
@@ -513,7 +514,7 @@ def _get_field(cls, a_name, a_type):
513 514 # and InitVars are also returned, but marked as such (see
514 515 # f._field_type).
515 516
516 -# If the default value isn't derived from field, then it's
517 +# If the default value isn't derived from Field, then it's
517 518 # only a normal default value. Convert it to a Field().
518 519 default = getattr(cls, a_name, MISSING)
519 520 if isinstance(default, Field):
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
1 -from dataclasses import (
2 -dataclass, field, FrozenInstanceError, fields, asdict, astuple,
3 -make_dataclass, replace, InitVar, Field, MISSING, is_dataclass,
4 -)
1 +# Deliberately use "from dataclasses import *". Every name in __all__
2 +# is tested, so they all must be present. This is a way to catch
3 +# missing ones.
4 +
5 +from dataclasses import *
5 6
6 7 import pickle
7 8 import inspect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 +Add 'Field' to dataclasses.__all__.