For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
check_arguments_arity
def check_arguments_arity(arity: Int, args: PythonObject)
Validate that the provided arguments match the expected function arity.
This function checks if the number of arguments in the provided tuple object 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 (
PythonObject): A tuple containing the actual arguments passed to the function.
Raises:
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.
def check_arguments_arity(arity: Int, args: PythonObject, func_name: StringSlice)
Validate that the provided arguments match the expected function arity.
This function checks if the number of arguments in the provided tuple object 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 (
PythonObject): A tuple containing the actual arguments passed to the function. - func_name (
StringSlice): The name of the function being called, used in error messages to provide better debugging information.
Raises:
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.
def check_arguments_arity(arity: Int, arg_count: Int)
Validate that the provided argument count matches the expected arity.
Fastcall-friendly overload: takes the already-known number of positional
arguments rather than computing it from a tuple object. Used by the
METH_FASTCALL dispatch path, which receives nargs: Py_ssize_t
directly from CPython and never materializes a tuple.
Args:
- arity (
Int): The expected number of arguments for the function. - arg_count (
Int): The actual number of arguments passed to the function.
Raises:
If arg_count differs from arity. The error message follows
Python's TypeError convention.
def check_arguments_arity(arity: Int, arg_count: Int, func_name: StringSlice)
Validate that the provided argument count matches the expected arity.
Fastcall-friendly overload that accepts a precomputed arg count and a
function name. See the arg_count-only overload for the rationale.
Args:
- arity (
Int): The expected number of arguments for the function. - arg_count (
Int): The actual number of arguments passed to the function. - func_name (
StringSlice): The name of the function being called, used in error messages.
Raises:
If arg_count differs from arity.