mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	bpo-33517: dataclasses: Add the field type to Field repr (GH-6858)
This commit is contained in:
		
							parent
							
								
									540162260c
								
							
						
					
					
						commit
						01abc6ec3a
					
				
					 1 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
					@ -166,9 +166,14 @@ class _MISSING_TYPE:
 | 
				
			||||||
_EMPTY_METADATA = types.MappingProxyType({})
 | 
					_EMPTY_METADATA = types.MappingProxyType({})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Markers for the various kinds of fields and pseudo-fields.
 | 
					# Markers for the various kinds of fields and pseudo-fields.
 | 
				
			||||||
_FIELD = object()                 # An actual field.
 | 
					class _FIELD_BASE:
 | 
				
			||||||
_FIELD_CLASSVAR = object()        # Not a field, but a ClassVar.
 | 
					    def __init__(self, name):
 | 
				
			||||||
_FIELD_INITVAR = object()         # Not a field, but an InitVar.
 | 
					        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
 | 
					# 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.
 | 
					#  objects. Also used to check if a class is a Data Class.
 | 
				
			||||||
| 
						 | 
					@ -237,7 +242,8 @@ def __repr__(self):
 | 
				
			||||||
                f'repr={self.repr!r},'
 | 
					                f'repr={self.repr!r},'
 | 
				
			||||||
                f'hash={self.hash!r},'
 | 
					                f'hash={self.hash!r},'
 | 
				
			||||||
                f'compare={self.compare!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
 | 
					    # This is used to support the PEP 487 __set_name__ protocol in the
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue