Build dynamic enum with an empty __dict__ to be filled once memoized The creation of the enum class is inspired by the code of EnumMeta._create_. If class_tracker_id is not None, try to lookup an existing enum definition matching that id. If none is found, track a newly reconstruct
(
bases, name, qualname, members, module, class_tracker_id, extra
)
| 565 | |
| 566 | |
| 567 | def _make_skeleton_enum( |
| 568 | bases, name, qualname, members, module, class_tracker_id, extra |
| 569 | ): |
| 570 | """Build dynamic enum with an empty __dict__ to be filled once memoized |
| 571 | |
| 572 | The creation of the enum class is inspired by the code of |
| 573 | EnumMeta._create_. |
| 574 | |
| 575 | If class_tracker_id is not None, try to lookup an existing enum definition |
| 576 | matching that id. If none is found, track a newly reconstructed enum |
| 577 | definition under that id so that other instances stemming from the same |
| 578 | class id will also reuse this enum definition. |
| 579 | |
| 580 | The "extra" variable is meant to be a dict (or None) that can be used for |
| 581 | forward compatibility shall the need arise. |
| 582 | """ |
| 583 | # enums always inherit from their base Enum class at the last position in |
| 584 | # the list of base classes: |
| 585 | enum_base = bases[-1] |
| 586 | metacls = enum_base.__class__ |
| 587 | classdict = metacls.__prepare__(name, bases) |
| 588 | |
| 589 | for member_name, member_value in members.items(): |
| 590 | classdict[member_name] = member_value |
| 591 | enum_class = metacls.__new__(metacls, name, bases, classdict) |
| 592 | enum_class.__module__ = module |
| 593 | enum_class.__qualname__ = qualname |
| 594 | |
| 595 | return _lookup_class_or_track(class_tracker_id, enum_class) |
| 596 | |
| 597 | |
| 598 | def _make_typevar(name, bound, constraints, covariant, contravariant, class_tracker_id): |
nothing calls this directly
no test coverage detected