import inspect


def _get_signature(cls, drop_positional_only=False):
    """

    >>> _get_signature(dict)
    <Signature (**kwargs)>
    >>> _get_signature(list)
    <Signature (iterable=(), /)>
    >>> _get_signature(tuple)
    <Signature (iterable=(), /)>
    >>> _get_signature(set)
    <Signature (iterable=(), /)>

    >>> inspect.signature(dict)
    Traceback (most recent call last):
    ...
    ValueError: no signature found for builtin type <class 'dict'>
    >>> inspect.signature(set)
    Traceback (most recent call last):
    ...
    ValueError: no signature found for builtin type <class 'set'>

    """
    if cls in [
        set,  # py38: set missing signature
        tuple,  # py36: tuple missing signature (available in py37)
        list,  # py36: list missing signature (available in py37)
    ]:
        sig = inspect.Signature(
            parameters=[inspect.Parameter(
                'iterable', inspect.Parameter.POSITIONAL_ONLY,
                default=(),
            )]
        )
    elif cls in [dict]:
        # Dict has no correct signature, hence return the signature, that is
        # needed here.
        sig = inspect.Signature(
            parameters=[inspect.Parameter(
                'kwargs', inspect.Parameter.VAR_KEYWORD,
            )]
        )
    else:
        sig = inspect.signature(cls)

    if drop_positional_only:
        sig = sig.replace(
            parameters=[
                p
                for p in sig.parameters.values()
                if p.kind != inspect.Parameter.POSITIONAL_ONLY
            ]
        )
    return sig