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
01abc6ec
Commit
01abc6ec
authored
May 15, 2018
by
Eric V. Smith
Committed by
GitHub
May 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-33517: dataclasses: Add the field type to Field repr (GH-6858)
parent
54016226
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
Lib/dataclasses.py
Lib/dataclasses.py
+10
-4
No files found.
Lib/dataclasses.py
View file @
01abc6ec
...
...
@@ -166,9 +166,14 @@ MISSING = _MISSING_TYPE()
_EMPTY_METADATA
=
types
.
MappingProxyType
({})
# Markers for the various kinds of fields and pseudo-fields.
_FIELD
=
object
()
# An actual field.
_FIELD_CLASSVAR
=
object
()
# Not a field, but a ClassVar.
_FIELD_INITVAR
=
object
()
# Not a field, but an InitVar.
class
_FIELD_BASE
:
def
__init__
(
self
,
name
):
self
.
name
=
name
def
__repr__
(
self
):
return
self
.
name
_FIELD
=
_FIELD_BASE
(
'_FIELD'
)
_FIELD_CLASSVAR
=
_FIELD_BASE
(
'_FIELD_CLASSVAR'
)
_FIELD_INITVAR
=
_FIELD_BASE
(
'_FIELD_INITVAR'
)
# The name of an attribute on the class where we store the Field
# objects. Also used to check if a class is a Data Class.
...
...
@@ -237,7 +242,8 @@ class Field:
f'repr=
{
self
.
repr
!
r
}
,'
f'hash=
{
self
.
hash
!
r
}
,'
f'compare=
{
self
.
compare
!
r
}
,'
f'metadata=
{
self
.
metadata
!
r
}
'
f'metadata=
{
self
.
metadata
!
r
}
,'
f'_field_type=
{
self
.
_field_type
}
'
')'
)
# This is used to support the PEP 487 __set_name__ protocol in the
...
...
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