from typing import Any


def import_object(import_path: str) -> Any:
    """Import the object at the given import path.

    Import paths consist of the dotted module name, optionally followed by a
    colon or dot, and the module attribute at which the object is located.

    For example:

    - ``json``
    - ``os.path``
    - ``xml.sax.saxutils:escape``
    - ``xml.sax.saxutils.escape``

    This function mirrors the implementation of ``jinja2.utils.import_string``.
    """
    if ":" in import_path:
        module_name, _, attribute = import_path.rpartition(":")
    elif "." in import_path:
        module_name, _, attribute = import_path.rpartition(".")
    else:
        return __import__(import_path)

    module = __import__(module_name, None, None, [attribute])
    return getattr(module, attribute)