from typing import Callable
import inspect


def get_required_parameters_number(callable_object: Callable) -> int:
    """
    Checks if a callable object has the correct number of required parameters.

    .. versionadded:: 0.0.2

    A callable object can be a function or a method.

    Parameters
    ----------
    callable_object : callable
        A callable object to be tested.

    Raises
    ------
    TypeError
        The ``callable_object`` is not a Python callable, i.e., a function or
        a method.

    Returns
    -------
    required_param_n : integer
        The number of required parameters that ``callable_object`` takes.
    """
    if not callable(callable_object):
        raise TypeError('The callable_object should be Python callable, e.g., '
                        'a function or a method.')

    required_param_n = 0
    params = inspect.signature(callable_object).parameters
    for param in params:
        if param != 'kwargs':
            if params[param].default is params[param].empty:
                required_param_n += 1

    return required_param_n