Get a reasonable method resolution order of a class and its superclasses for both old-style and new-style classes.
(obj_class)
| 321 | |
| 322 | |
| 323 | def _get_mro(obj_class): |
| 324 | """ Get a reasonable method resolution order of a class and its superclasses |
| 325 | for both old-style and new-style classes. |
| 326 | """ |
| 327 | if not hasattr(obj_class, '__mro__'): |
| 328 | # Old-style class. Mix in object to make a fake new-style class. |
| 329 | try: |
| 330 | obj_class = type(obj_class.__name__, (obj_class, object), {}) |
| 331 | except TypeError: |
| 332 | # Old-style extension type that does not descend from object. |
| 333 | # FIXME: try to construct a more thorough MRO. |
| 334 | mro = [obj_class] |
| 335 | else: |
| 336 | mro = obj_class.__mro__[1:-1] |
| 337 | else: |
| 338 | mro = obj_class.__mro__ |
| 339 | return mro |
| 340 | |
| 341 | |
| 342 | class RepresentationPrinter(PrettyPrinter): |
no outgoing calls
no test coverage detected
searching dependent graphs…