(defined_fields, inherited_slots, field_names, weakref_slot)
| 1302 | |
| 1303 | |
| 1304 | def _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 | |
| 1329 | def _add_slots(cls, is_frozen, weakref_slot, defined_fields): |
no test coverage detected
searching dependent graphs…