from datetime import datetime


def isoformat(dt: datetime) -> str:
    """ISO format datetime object with max precision limited to seconds.

    Args:
        dt: datatime object to be formatted

    Returns:
        ISO 8601 formatted string

    """
    # IMPORTANT should the format be ever changed, be sure to update TIMESTAMP_REGEX as well!
    return dt.isoformat(timespec="seconds")