from typing import Optional


def get_human_format_resistance(resistance: Optional[float],
                                ndigits: int = 1) -> Optional[str]:
    """Return human format resistance.

    Parameters
    ----------
    resistance : float, optional
        Resistance value. Unit ``Ω``. If ``None``, return ``None``.
    ndigits : int
        Digit number after decimal point. By default ``1``.

    Returns
    -------
    str or None
    """
    if resistance is None:
        return None
    units = ('', 'K', 'M')
    for unit in units:
        if abs(resistance) < 1000:
            return f'{resistance:.{ndigits}f}{unit}'
        else:
            resistance = resistance / 1000
    else:
        raise ValueError(f'No unit for {resistance:E}.')