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. |
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.
"""
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
]
|