import inspect
from typing import Dict
from typing import List


def parse_method_signature(
    signature: inspect.Signature, param_dict: Dict[str, str]
) -> List[List[str]]:
    """Combines Signature with the contents of a param_dict to create rows for a parameter table.

    Args:
        signature: the output from running `inspect.signature` on a method
        param_dict: dictionary of parameter: parameter description key: values for the inspected method.

    Returns:
        A list containing lists of strings, each of which represents one row in a parameter's table.  The rows are in
        the format [parameter name, parameter typing, parameter default value, parameter description].

    """
    sig_type = ""
    sig_default = ""
    sig_results = []
    for key, value in signature.parameters.items():
        value = str(value)
        if ":" in value:
            sig_parameter, remainder = value.split(":", 1)
            if "=" in remainder:
                sig_type, sig_default = remainder.rsplit("=", 1)
            else:
                sig_type = remainder
        elif "=" in value:
            sig_parameter, sig_default = value.split("=", 1)
        else:
            sig_parameter = value
        sig_results.append(
            [sig_parameter, sig_type, sig_default, param_dict.get(sig_parameter, "")]
        )
    return sig_results