Repository: yt-dlp/yt-dlp
File: yt_dlp/utils.py (Python)

Code before:
                has_branched = True

            if __debug__ and callable(key):
                inspect.signature(key).bind(None, None)

            key_func = functools.partial(apply_key, key)
            objs = itertools.chain.from_iterable(map(key_func, objs))

        return has_branched, objs

    def _traverse_obj(obj, path, use_list=True):
        has_branched, results = apply_path(obj, path)
        results = LazyList(x for x in map(type_test, results) if x is not None)

        if get_all and has_branched:
            return results.exhaust() if results or use_list else None

        return results[0] if results else None

    for index, path in enumerate(paths, 1):
        use_list = default is NO_DEFAULT and index == len(paths)
        result = _traverse_obj(obj, path, use_list)
        if result is not None:
            return result

    return None if default is NO_DEFAULT else default


def traverse_dict(dictn, keys, casesense=True):
    deprecation_warning(f'"{__name__}.traverse_dict" is deprecated and may be removed '
                        f'in a future version. Use "{__name__}.traverse_obj" instead')
    return traverse_obj(dictn, keys, casesense=casesense, is_user_input=True, traverse_string=True)


def get_first(obj, keys, **kwargs):
    return traverse_obj(obj, (..., *variadic(keys)), **kwargs, get_all=False)


def time_seconds(**kwargs):
    t = datetime.datetime.now(datetime.timezone(datetime.timedelta(**kwargs)))
    return t.timestamp()


# create a JSON Web Signature (jws) with HS256 algorithm
# the resulting format is in JWS Compact Serialization
# implemented following JWT https://www.rfc-editor.org/rfc/rfc7519.html
# implemented following JWS https://www.rfc-editor.org/rfc/rfc7515.html
def jwt_encode_hs256(payload_data, key, headers={}):
    header_data = {
        'alg': 'HS256',
        'typ': 'JWT',

Review comment (suggestion):
```suggestion
                inspect.signature(key).bind(None, None)  # Verify function signature
```

Code after:
            return

        for item in iterator:
            yield False, prev
            prev = item

        yield True, prev

    def apply_path(start_obj, path, test_type=False):
        objs = (start_obj,)
        has_branched = False

        key = None
        for last, key in lazy_last(variadic(path, (str, bytes, dict, set))):
            if is_user_input and key == ':':
                key = ...

            if not casesense and isinstance(key, str):
                key = key.casefold()

            if key is ... or isinstance(key, (list, tuple)) or callable(key):
                has_branched = True

            if __debug__ and callable(key):
                # Verify function signature
                inspect.signature(key).bind(None, None)

            key_func = functools.partial(apply_key, key, last)
            objs = itertools.chain.from_iterable(map(key_func, objs))

        if test_type and not isinstance(key, (dict, list, tuple)):
            objs = map(type_test, objs)

        return has_branched, objs

    def _traverse_obj(obj, path, use_list=True, test_type=True):
        has_branched, results = apply_path(obj, path, test_type)
        results = LazyList(x for x in results if x is not None)

        if get_all and has_branched:
            return results.exhaust() if results or use_list else None

        return results[0] if results else None

    for index, path in enumerate(paths, 1):
        use_list = default is NO_DEFAULT and index == len(paths)
        result = _traverse_obj(obj, path, use_list)
        if result is not None:
            return result

    return None if default is NO_DEFAULT else default