Skip to content

Commit

Permalink
bpo-33116: Add 'Field' to dataclasses.__all__. (GH-6182) (GH-6183)
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
miss-islington and ericvsmith committed Mar 21, 2018
1 parent f5625d5 commit 4ddc99d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

__all__ = ['dataclass',
'field',
'Field',
'FrozenInstanceError',
'InitVar',
'MISSING',
Expand Down Expand Up @@ -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):
Expand Down
9 changes: 5 additions & 4 deletions Lib/test/test_dataclasses.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add 'Field' to dataclasses.__all__.

0 comments on commit 4ddc99d

Please sign in to comment.