Lines Matching refs:default

62 # | True  | add   |       |  <- the default
74 # | True | add | | <- the default
86 # | False | | | <- the default
102 # | True | add | | <- the default
115 # | False | | | <- the default
135 # | False | True | False | None | | <-- the default, not hashable
166 # | True | add | | <- the default
175 # A sentinel object for default values to signal that a default
190 # default. Use a class to give it a better repr.
276 'default',
287 def __init__(self, default, default_factory, init, repr, hash, compare,
291 self.default = default
308 f'default={self.default!r},'
321 # default value. For details on __set_name__, see
325 # with the default value, so the end result is a descriptor that
328 func = getattr(type(self.default), '__set_name__', None)
332 func(self.default, owner, name)
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
383 It is an error to specify both default and default_factory.
386 if default is not MISSING and default_factory is not MISSING:
387 raise ValueError('cannot specify both default and default_factory')
388 return Field(default, default_factory, init, repr, hash, compare,
456 # This field has a default factory. If a parameter is
464 # has a default factory function. It needs to be
468 # For a field initialized with a default=defaultvalue, the
469 # class dict just has the default value
471 # default factory, the factory must be called in __init__
480 # No default factory.
482 if f.default is MISSING:
483 # There's no default, just do an assignment.
485 elif f.default is not MISSING:
486 globals[default_name] = f.default
490 if slots and f.default is not MISSING:
491 globals[default_name] = f.default
495 # just use the class attribute that contains the default.
500 # default. However, return None to signify that we're not going
514 if f.default is MISSING and f.default_factory is MISSING:
515 # There's no default, and no default_factory, just output the
517 default = ''
518 elif f.default is not MISSING:
519 # There's a default, this will be the name that's used to look
521 default = f'=_dflt_{f.name}'
524 default = '=_HAS_DEFAULT_FACTORY'
525 return f'{f.name}:_type_{f.name}{default}'
542 if not (f.default is MISSING and f.default_factory is MISSING):
545 raise TypeError(f'non-default argument {f.name!r} '
546 'follows default argument')
729 # If the default value isn't derived from Field, then it's only a
730 # normal default value. Convert it to a Field().
731 default = getattr(cls, a_name, MISSING)
732 if isinstance(default, Field):
733 f = default
735 if isinstance(default, types.MemberDescriptorType):
736 # This is a field in __slots__, so it has no default value.
737 default = MISSING
738 f = field(default=default)
791 'default factory')
795 # init=<not-the-default-init-value>)? It makes no sense for
801 # default value.
814 if f._field_type is _FIELD and f.default.__class__.__hash__ is None:
815 raise ValueError(f'mutable default {type(f.default)} for field '
929 # has a default. If the default value is a Field(), then it
931 # actual default value. Pseudo-fields ClassVars and InitVars are
937 # things, and set the default values (as class attributes) where
949 # Switch the default to kw_only=True, and ignore this
963 # If the class attribute (which is the default value for this
965 # real default. This is so that normal class introspection
966 # sees a real default value, not a Field.
968 if f.default is MISSING:
969 # If there's no default, delete the class attribute.
972 # no default value). Also if we're using a default
977 setattr(cls, f.name, f.default)
1214 __match_args__ tuple is added. If kw_only is true, then by default
1491 if f._field_type is _FIELD_INITVAR and f.default is MISSING: