• Home
  • Raw
  • Download

Lines Matching +full:- +full:- +full:add +full:- +full:missing

21            'MISSING',
45 # +---------+-----------------------------------------+
46 # | add | Generated method is added. |
47 # +---------+-----------------------------------------+
49 # +---------+-----------------------------------------+
55 # +--- init= parameter
58 # | no | yes | <--- class has __init__ in __dict__?
61 # +-------+-------+-------+
62 # | True | add | | <- the default
67 # +--- repr= parameter
70 # | no | yes | <--- class has __repr__ in __dict__?
73 # +-------+-------+-------+
74 # | True | add | | <- the default
81 # +--- frozen= parameter
84 # | no | yes | <--- class has __setattr__ or __delattr__ in __dict__?
86 # | False | | | <- the default
87 # +-------+-------+-------+
88 # | True | add | raise |
90 # Raise because not adding these methods would break the "frozen-ness"
95 # +--- eq= parameter
98 # | no | yes | <--- class has __eq__ in __dict__?
101 # +-------+-------+-------+
102 # | True | add | | <- the default
110 # +--- order= parameter
113 # | no | yes | <--- class has any comparison method in __dict__?
115 # | False | | | <- the default
116 # +-------+-------+-------+
117 # | True | add | raise |
124 # +------------------- unsafe_hash= parameter
125 # | +----------- eq= parameter
126 # | | +--- frozen= parameter
129 # | no | yes | <--- class has explicitly defined __hash__
132 # +-------+-------+-------+--------+--------+
134 # +-------+-------+-------+--------+--------+
135 # | False | True | False | None | | <-- the default, not hashable
136 # +-------+-------+-------+--------+--------+
137 # | False | True | True | add | | Frozen, so hashable, allows override
138 # +-------+-------+-------+--------+--------+
139 # | True | False | False | add | raise | Has no __eq__, but hashable
140 # +-------+-------+-------+--------+--------+
141 # | True | False | True | add | raise | Has no __eq__, but hashable
142 # +-------+-------+-------+--------+--------+
143 # | True | True | False | add | raise | Not frozen, but hashable
144 # +-------+-------+-------+--------+--------+
145 # | True | True | True | add | raise | Frozen, so hashable
149 # id-based hashing is used.
159 # +--- match_args= parameter
162 # | no | yes | <--- class has __match_args__ in __dict__?
165 # +-------+-------+-------+
166 # | True | add | | <- the default
169 # tuple of __init__ parameter names; non-init fields must be matched by keyword.
187 MISSING = _MISSING_TYPE() variable
189 # A sentinel object to indicate that following fields are keyword-only by
195 # Since most per-field metadata will be unused, create an empty
196 # read-only proxy that can be shared among all fields.
199 # Markers for the various kinds of fields and pseudo-fields.
238 repr_running.add(key)
265 # exposed externally as (conceptually) read-only objects.
322 # https://peps.python.org/pep-0487/#implementation-details.
368 def field(*, default=MISSING, default_factory=MISSING, init=True, repr=True,
369 hash=None, compare=True, metadata=None, kw_only=MISSING):
373 0-argument function called to initialize a field's value. If init
380 is true, the field will become a keyword-only parameter to
386 if default is not MISSING and default_factory is not MISSING:
406 # Special case for the 0-tuple.
409 # Note the trailing comma, needed if this turns out to be a 1-tuple.
414 return_type=MISSING):
421 if return_type is not MISSING:
423 return_annotation = '->_return_type'
443 # hard-code "self", since that might be a field name.
454 if f.default_factory is not MISSING:
474 # not set, and because it might be different per-class
482 if f.default is MISSING:
485 elif f.default is not MISSING:
490 if slots and f.default is not MISSING:
514 if f.default is MISSING and f.default_factory is MISSING:
518 elif f.default is not MISSING:
522 elif f.default_factory is not MISSING:
530 # fields contains both real fields and InitVar pseudo-fields.
533 # with defaults. This actually would be caught when exec-ing the
535 # message, and future-proofs us in case we build up the function
540 # Only consider the non-kw-only fields in the __init__ call.
542 if not (f.default is MISSING and f.default_factory is MISSING):
545 raise TypeError(f'non-default argument {f.name!r} '
550 'MISSING': MISSING,
559 # initialization (it's a pseudo-field). Just skip it.
563 # Does this class have a post-init function?
575 # Add the keyword-only args. Because the * can only be added if
576 # there's at least one keyword-only arg, there needs to be a test here
605 # Special case for the zero-length tuple.
674 # - annotation is a string type annotation
675 # - cls is the class that this annotation was found in
676 # - a_module is the module we want to match
677 # - a_type is the type in that module we want to match
678 # - is_type_predicate is a function called with (obj, a_module)
731 default = getattr(cls, a_name, MISSING)
737 default = MISSING
789 if f.default_factory is not MISSING:
793 # seems the most serious to check for. Maybe add others. For
795 # init=<not-the-default-init-value>)? It makes no sense for
802 if f.kw_only is MISSING:
807 if f.kw_only is not MISSING:
838 # (unsafe_hash, eq, frozen, does-hash-exist). Value is the action to
840 # function that is a no-op, use None to signify that.
855 # +-------------------------------------- unsafe_hash?
856 # | +------------------------------- eq?
857 # | | +------------------------ frozen?
858 # | | | +---------------- has-explicit-hash?
860 # | | | | +------- action
880 # See https://bugs.python.org/issue32929#msg312829 for an if-statement
911 for b in cls.__mro__[-1:0:-1]:
931 # actual default value. Pseudo-fields ClassVars and InitVars are
968 if f.default is MISSING:
974 # all in the post-processed class.
988 raise TypeError('cannot inherit non-frozen dataclass from a '
994 'non-frozen one')
1003 # that such a __hash__ == None was not auto-generated, but it
1005 class_hash = cls.__dict__.get('__hash__', MISSING)
1006 has_explicit_hash = not (class_hash is MISSING or
1023 # Does this class have a post-init function?
1094 # Create a class doc-string.
1098 text_sig = str(inspect.signature(cls)).replace(' -> None', '')
1160 itertools.chain.from_iterable(map(_get_slots, cls.__mro__[1:-1]))
1162 # The slots for our class. Remove slots from our base classes. Add
1168 # gh-93521: '__weakref__' also needs to be filtered out if
1184 cls_dict.pop('__weakref__', None) # gh-102069
1205 """Add dunder methods based on the fields defined in the class.
1215 all fields are keyword-only. If slots is true, a new class with a
1246 # Exclude pseudo-fields. Note that fields is sorted by insertion
1277 If given, 'dict_factory' will be used instead of built-in dict.
1279 dataclass instances. This will also look into built-in containers:
1297 # similar to how other list- or tuple-derived classes are
1300 # called differently (see bpo-34363).
1304 # - it does not recurse in to the namedtuple fields and
1306 # - I don't actually want to return a dict here. The main
1341 If given, 'tuple_factory' will be used instead of built-in tuple.
1343 dataclass instances. This will also look into built-in containers:
1362 # similar to how other list- or tuple-derived classes are
1365 # called differently (see bpo-34363).
1388 the equivalent of calling 'field(name, type [, Field-info])'.::
1433 seen.add(name)
1436 # Update 'ns' with the user-supplied namespace plus our calculated values.
1491 if f._field_type is _FIELD_INITVAR and f.default is MISSING: