MCPcopy
hub / github.com/python-telegram-bot/python-telegram-bot / mro_slots

Function mro_slots

tests/auxil/slots.py:22–38  ·  view source on GitHub ↗

Returns a list of all slots of a class and its parents. Args: obj (:obj:`type`): The class or class-instance to get the slots from. only_parents (:obj:`bool`, optional): If ``True``, only the slots of the parents are returned. Defaults to ``False``.

(obj, only_parents: bool = False)

Source from the content-addressed store, hash-verified

20
21
22def mro_slots(obj, only_parents: bool = False):
23 """Returns a list of all slots of a class and its parents.
24 Args:
25 obj (:obj:`type`): The class or class-instance to get the slots from.
26 only_parents (:obj:`bool`, optional): If ``True``, only the slots of the parents are
27 returned. Defaults to ``False``.
28 """
29 cls = obj if inspect.isclass(obj) else obj.__class__
30
31 classes = cls.__mro__[1:] if only_parents else cls.__mro__
32
33 return [
34 attr
35 for cls in classes
36 if hasattr(cls, "__slots__") # The Exception class doesn't have slots
37 for attr in cls.__slots__
38 ]

Callers 15

test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slotsMethod · 0.90
test_slot_behaviourMethod · 0.90
test_slot_behaviourMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slotsMethod · 0.72
test_slot_behaviourMethod · 0.72
test_slot_behaviourMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…