MCPcopy Index your code
hub / github.com/python/cpython / _create_slots

Function _create_slots

Lib/dataclasses.py:1304–1326  ·  view source on GitHub ↗
(defined_fields, inherited_slots, field_names, weakref_slot)

Source from the content-addressed store, hash-verified

1302
1303
1304def _create_slots(defined_fields, inherited_slots, field_names, weakref_slot):
1305 # The slots for our class. Remove slots from our base classes. Add
1306 # '__weakref__' if weakref_slot was given, unless it is already present.
1307 seen_docs = False
1308 slots = {}
1309 for slot in itertools.filterfalse(
1310 inherited_slots.__contains__,
1311 itertools.chain(
1312 # gh-93521: '__weakref__' also needs to be filtered out if
1313 # already present in inherited_slots
1314 field_names, ('__weakref__',) if weakref_slot else ()
1315 )
1316 ):
1317 doc = getattr(defined_fields.get(slot), 'doc', None)
1318 if doc is not None:
1319 seen_docs = True
1320 slots[slot] = doc
1321
1322 # We only return dict if there's at least one doc member,
1323 # otherwise we return tuple, which is the old default format.
1324 if seen_docs:
1325 return slots
1326 return tuple(slots)
1327
1328
1329def _add_slots(cls, is_frozen, weakref_slot, defined_fields):

Callers 1

_add_slotsFunction · 0.85

Calls 2

chainMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…