HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python311/lib/python3.11/site-packages/typish/functions/_get_mro.py
import typing
from inspect import getmro


def get_mro(obj: typing.Any) -> typing.Tuple[type, ...]:
    """
    Return tuple of base classes (including that of obj) in method resolution
    order. Types from typing are supported as well.
    :param obj: object or type.
    :return: a tuple of base classes.
    """
    from typish.functions._get_origin import get_origin

    # Wrapper around ``getmro`` to allow types from ``typing``.
    if obj is ...:
        return Ellipsis, object
    elif obj is typing.Union:
        # For Python <3.7, we cannot use mro.
        super_cls = getattr(typing, '_GenericAlias',
                            getattr(typing, 'GenericMeta', None))
        return typing.Union, super_cls, object

    origin = get_origin(obj)
    if origin != obj:
        return get_mro(origin)

    cls = obj
    if not isinstance(obj, type):
        cls = type(obj)

    return getmro(cls)