import typing
import inspect


def _inspect_signature(slot: typing.Callable) -> typing.Optional[int]:
    """
    count maximal number of positional argument
    :param slot: callable to be checked
    :return: number of parameters which could be passed to callable, None if unbound
    """
    if hasattr(slot, "__module__") and isinstance(slot.__module__, str) and slot.__module__.startswith("superqt"):
        return 0
    try:
        signature = inspect.signature(slot)
    except ValueError:
        return 0
    count = 0
    for parameter in signature.parameters.values():
        if parameter.kind in [inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD]:
            count += 1
        if parameter.kind == inspect.Parameter.VAR_POSITIONAL:
            count = None
            break
    return count