Skip to content

get_function_positional_arguments

faststream.utils.functions.get_function_positional_arguments #

get_function_positional_arguments(
    func: AnyCallable,
) -> List[str]

Get the positional arguments of a function.

PARAMETER DESCRIPTION
func

The function to get the positional arguments from.

TYPE: AnyCallable

RETURNS DESCRIPTION
List[str]

A list of strings representing the names of the positional arguments.

Note

The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)

Source code in faststream/utils/functions.py
def get_function_positional_arguments(func: AnyCallable) -> List[str]:
    """Get the positional arguments of a function.

    Args:
        func: The function to get the positional arguments from.

    Returns:
        A list of strings representing the names of the positional arguments.
    !!! note

        The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
    """
    signature = inspect.signature(func)

    arg_kinds = (
        inspect.Parameter.POSITIONAL_ONLY,
        inspect.Parameter.POSITIONAL_OR_KEYWORD,
    )

    return [
        param.name for param in signature.parameters.values() if param.kind in arg_kinds
    ]

Last update: 2023-11-13