Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8e4560a9
Commit
8e4560a9
authored
Mar 21, 2018
by
Eric V. Smith
Committed by
GitHub
Mar 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add 'Field' to dataclasses.__all__. (GH-6182)
- Add missing 'Field' to __all__. - Improve tests to catch this.
parent
dec1c778
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
Lib/dataclasses.py
Lib/dataclasses.py
+2
-1
Lib/test/test_dataclasses.py
Lib/test/test_dataclasses.py
+5
-4
Misc/NEWS.d/next/Library/2018-03-21-16-52-26.bpo-33116.Tvzerj.rst
...S.d/next/Library/2018-03-21-16-52-26.bpo-33116.Tvzerj.rst
+1
-0
No files found.
Lib/dataclasses.py
View file @
8e4560a9
...
...
@@ -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
f
ield, then it's
# If the default value isn't derived from
F
ield, then it's
# only a normal default value. Convert it to a Field().
default
=
getattr
(
cls
,
a_name
,
MISSING
)
if
isinstance
(
default
,
Field
):
...
...
Lib/test/test_dataclasses.py
View file @
8e4560a9
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
...
...
Misc/NEWS.d/next/Library/2018-03-21-16-52-26.bpo-33116.Tvzerj.rst
0 → 100644
View file @
8e4560a9
Add 'Field' to dataclasses.__all__.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment