$17 GRAYBYTE WORDPRESS FILE MANAGER $80

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 88.222.243.106 | ADMIN IP 216.73.216.215
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/python311/lib/python3.11/site-packages/typish/functions/

HOME
Current File : /opt/alt/python311/lib/python3.11/site-packages/typish/functions//_common_ancestor.py
import typing


def common_ancestor(*args: object) -> type:
    """
    Get the closest common ancestor of the given objects.
    :param args: any objects.
    :return: the ``type`` of the closest common ancestor of the given ``args``.
    """
    return _common_ancestor(args, False)


def common_ancestor_of_types(*args: type) -> type:
    """
    Get the closest common ancestor of the given classes.
    :param args: any classes.
    :return: the ``type`` of the closest common ancestor of the given ``args``.
    """
    return _common_ancestor(args, True)


def _common_ancestor(args: typing.Sequence[object], types: bool) -> type:
    from typish.functions._get_type import get_type
    from typish.functions._get_mro import get_mro

    if len(args) < 1:
        raise TypeError('common_ancestor() requires at least 1 argument')
    tmap = (lambda x: x) if types else get_type
    mros = [get_mro(tmap(elem)) for elem in args]
    for cls in mros[0]:
        for mro in mros:
            if cls not in mro:
                break
        else:
            # cls is in every mro; a common ancestor is found!
            return cls

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
8 May 2024 6.34 PM
root / root
0755
__pycache__
--
8 May 2024 6.34 PM
root / root
0755
__init__.py
0 KB
8 May 2024 6.34 PM
root / root
0644
_common_ancestor.py
1.146 KB
8 May 2024 6.34 PM
root / root
0644
_get_alias.py
1.206 KB
8 May 2024 6.34 PM
root / root
0644
_get_args.py
0.421 KB
8 May 2024 6.34 PM
root / root
0644
_get_mro.py
0.919 KB
8 May 2024 6.34 PM
root / root
0644
_get_origin.py
1.126 KB
8 May 2024 6.34 PM
root / root
0644
_get_simple_name.py
0.54 KB
8 May 2024 6.34 PM
root / root
0644
_get_type.py
4.482 KB
8 May 2024 6.34 PM
root / root
0644
_get_type_hints_of_callable.py
1.595 KB
8 May 2024 6.34 PM
root / root
0644
_instance_of.py
1.497 KB
8 May 2024 6.34 PM
root / root
0644
_is_from_typing.py
0.247 KB
8 May 2024 6.34 PM
root / root
0644
_is_optional_type.py
0.633 KB
8 May 2024 6.34 PM
root / root
0644
_is_type_annotation.py
0.855 KB
8 May 2024 6.34 PM
root / root
0644
_subclass_of.py
5.729 KB
8 May 2024 6.34 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF