Lines Matching refs:field
16 'field',
195 # Since most per-field metadata will be unused, create an empty
264 # and only from the field() function, although Field instances are
320 # case where we're using a field that contains a descriptor as a
368 def field(*, default=MISSING, default_factory=MISSING, init=True, repr=True,
372 default is the default value of the field. default_factory is a
373 0-argument function called to initialize a field's value. If init
374 is true, the field will be a parameter to the class's __init__()
375 function. If repr is true, the field will be included in the
376 object's repr(). If hash is true, the field will be included in the
377 object's hash(). If compare is true, the field will be used in
380 is true, the field will become a keyword-only parameter to
402 # Return a string representing each field of obj_name as a tuple
443 # hard-code "self", since that might be a field name.
451 # initialize this field.
456 # This field has a default factory. If a parameter is
463 # This is a field that's not in the __init__ params, but
468 # For a field initialized with a default=defaultvalue, the
489 # If the class has slots, then initialize this field.
494 # This field does not need initialization: reading from it will
505 # Now, actually generate the field assignment.
510 # Return the __init__ parameter string for this field. For
558 # line is None means that this field doesn't require
559 # initialization (it's a pseudo-field). Just skip it.
610 ' raise FrozenInstanceError(f"cannot assign to field {name!r}")',
617 ' raise FrozenInstanceError(f"cannot delete field {name!r}")',
702 # a eval() penalty for every single field of every dataclass
724 # Return a Field object for this field name and type. ClassVars and
726 # default_kw_only is the value of kw_only to use if there isn't a field()
736 # This is a field in __slots__, so it has no default value.
738 f = field(default=default)
744 # Assume it's a normal field until proven otherwise. We're next
746 # is just a normal field.
785 # know the field name, which allows for better error reporting.
790 raise TypeError(f'field {f.name} cannot have a '
792 # Should I check for other field settings? default_factory
808 raise TypeError(f'field {f.name} is a ClassVar but specifies '
815 raise ValueError(f'mutable default {type(f.default)} for field '
907 # override earlier field definitions in base classes. As long as
928 # ordered. Default values are from class attributes, if a field
950 # annotation: it's not a real field.
957 # Otherwise it's a field of some type.
964 # field) exists and is of type 'Field', replace it with the
970 # This happens if we specify field(repr=False), for
971 # example (that is, we specified a field object, but
982 raise TypeError(f'{name!r} is a field but has no type annotation')
1128 for field, value in zip(fields(self), state):
1130 object.__setattr__(self, field.name, value)
1265 field names to field values.
1278 The function applies recursively to field values that are
1329 """Return the fields of a dataclass instance as a new tuple of field values.
1342 The function applies recursively to field values that are
1388 the equivalent of calling 'field(name, type [, Field-info])'.::
1390 C = make_dataclass('C', ['x', ('y', int), ('z', int, field(init=False))], bases=(Base,))
1398 z: int = field(init=False)
1409 # While we're looking through the field names, validate that they
1424 raise TypeError(f'Invalid field: {item!r}')
1475 # If a field is not in 'changes', read its value from the provided obj.
1483 # Error if this field is specified in changes.
1485 raise ValueError(f'field {f.name} is declared with '