Mojo function
check_arguments_arity
check_arguments_arity(arity: Int, args: TypedPythonObject[__init__[__mlir_type.!kgen.string]("Tuple")])
Validate that the provided arguments match the expected function arity.
This function checks if the number of arguments in the provided tuple matches the expected arity for a function call. If the counts don't match, it raises a descriptive error message similar to Python's built-in TypeError messages.
Args:
- arity (
Int
): The expected number of arguments for the function. - args (
TypedPythonObject[__init__[__mlir_type.!kgen.string]("Tuple")]
): A tuple containing the actual arguments passed to the function.
Raises:
Error: If the argument count doesn't match the expected arity. The error message follows Python's convention for TypeError messages, indicating whether too few or too many arguments were provided.
check_arguments_arity(arity: Int, args: TypedPythonObject[__init__[__mlir_type.!kgen.string]("Tuple")], func_name: StringSlice[origin])
Validate that the provided arguments match the expected function arity.
This function checks if the number of arguments in the provided tuple matches the expected arity for a function call. If the counts don't match, it raises a descriptive error message similar to Python's built-in TypeError messages.
Args:
- arity (
Int
): The expected number of arguments for the function. - args (
TypedPythonObject[__init__[__mlir_type.!kgen.string]("Tuple")]
): A tuple containing the actual arguments passed to the function. - func_name (
StringSlice[origin]
): The name of the function being called, used in error messages to provide better debugging information.
Raises:
Error: If the argument count doesn't match the expected arity. The error message follows Python's convention for TypeError messages, indicating whether too few or too many arguments were provided, along with the specific function name.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!