MCPcopy Create free account
hub / github.com/ipython/ipython / _get_mro

Function _get_mro

IPython/lib/pretty.py:305–321  ·  view source on GitHub ↗

Get a reasonable method resolution order of a class and its superclasses for both old-style and new-style classes.

(obj_class)

Source from the content-addressed store, hash-verified

303
304
305def _get_mro(obj_class):
306 """ Get a reasonable method resolution order of a class and its superclasses
307 for both old-style and new-style classes.
308 """
309 if not hasattr(obj_class, '__mro__'):
310 # Old-style class. Mix in object to make a fake new-style class.
311 try:
312 obj_class = type(obj_class.__name__, (obj_class, object), {})
313 except TypeError:
314 # Old-style extension type that does not descend from object.
315 # FIXME: try to construct a more thorough MRO.
316 mro = [obj_class]
317 else:
318 mro = obj_class.__mro__[1:-1]
319 else:
320 mro = obj_class.__mro__
321 return mro
322
323
324class RepresentationPrinter(PrettyPrinter):

Callers 2

prettyMethod · 0.85
_type_pprintFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected