Skip to content

vllm_mlx.cli_arg_types

Argparse type helpers shared by CLI entrypoints.

View the complete module source at #L1-L62.

API details

Each callable below includes its exact signature, type annotations, inputs, defaults, return contract, documented exceptions, implementation source, and parsed docstring sections when the source provides them.

vllm_mlx.cli_arg_types

Argparse type helpers shared by CLI entrypoints.

vllm_mlx.cli_arg_types.parse_json_object_arg

parse_json_object_arg(value: str, option_name: str) -> dict[str, Any]

Parse and validate that an option value is a JSON object.

Source code in vllm_mlx/cli_arg_types.py
def parse_json_object_arg(value: str, option_name: str) -> dict[str, Any]:
    """Parse and validate that an option value is a JSON object."""
    try:
        parsed = json.loads(value)
    except json.JSONDecodeError as exc:
        raise argparse.ArgumentTypeError(
            f"{option_name} must be a valid JSON object: {exc.msg}"
        ) from exc

    if not isinstance(parsed, dict):
        raise argparse.ArgumentTypeError(f"{option_name} must be a JSON object")

    return parsed

vllm_mlx.cli_arg_types.make_json_object_arg_parser

make_json_object_arg_parser(option_name: str) -> Callable[[str], dict[str, Any]]

Create an argparse type parser for JSON object options.

Source code in vllm_mlx/cli_arg_types.py
def make_json_object_arg_parser(option_name: str) -> Callable[[str], dict[str, Any]]:
    """Create an argparse type parser for JSON object options."""

    def _parser(value: str) -> dict[str, Any]:
        return parse_json_object_arg(value, option_name)

    return _parser

vllm_mlx.cli_arg_types.positive_int_arg

positive_int_arg(value: str) -> int

Parse an argparse integer that must be greater than zero.

Source code in vllm_mlx/cli_arg_types.py
def positive_int_arg(value: str) -> int:
    """Parse an argparse integer that must be greater than zero."""
    try:
        parsed = int(value)
    except ValueError as exc:
        raise argparse.ArgumentTypeError("must be an integer") from exc
    if parsed <= 0:
        raise argparse.ArgumentTypeError("must be greater than 0")
    return parsed

vllm_mlx.cli_arg_types.parse_positive_int_arg

parse_positive_int_arg(value: str, option_name: str) -> int

Parse and validate that an option value is a positive integer.

Source code in vllm_mlx/cli_arg_types.py
def parse_positive_int_arg(value: str, option_name: str) -> int:
    """Parse and validate that an option value is a positive integer."""
    try:
        parsed = int(value)
    except ValueError as exc:
        raise argparse.ArgumentTypeError(f"{option_name} must be an integer") from exc
    if parsed <= 0:
        raise argparse.ArgumentTypeError(f"{option_name} must be a positive integer")
    return parsed

vllm_mlx.cli_arg_types.make_positive_int_arg_parser

make_positive_int_arg_parser(option_name: str) -> Callable[[str], int]

Create an argparse type parser for positive integer options.

Source code in vllm_mlx/cli_arg_types.py
def make_positive_int_arg_parser(option_name: str) -> Callable[[str], int]:
    """Create an argparse type parser for positive integer options."""

    def _parser(value: str) -> int:
        return parse_positive_int_arg(value, option_name)

    return _parser

Complete contract reference

Expand any definition for its exact inputs, annotations, defaults, return contract, directly raised exceptions, source-grounded behavior, and immutable line link. This section includes private and nested definitions that ordinary API generators omit.

vllm_mlx.cli_arg_types.parse_json_object_arg · function
vllm_mlx.cli_arg_types.parse_json_object_arg(value: str, option_name: str) -> dict[str, Any]

Parse and validate that an option value is a JSON object.

Parameters

Name Type Required Default Description
value str yes none Required positional or keyword input.
option_name str yes none Required positional or keyword input.

Returns

  • Type: dict[str, Any]
  • Direct return expressions: parsed

Exceptions and behavior

Function parse_json_object_arg calls json.loads, argparse.ArgumentTypeError, isinstance; can raise argparse.ArgumentTypeError; returns parsed. Directly raised exceptions: argparse.ArgumentTypeError.

View source #L10-L22.

vllm_mlx.cli_arg_types.make_json_object_arg_parser · function
vllm_mlx.cli_arg_types.make_json_object_arg_parser(option_name: str) -> Callable[[str], dict[str, Any]]

Create an argparse type parser for JSON object options.

Parameters

Name Type Required Default Description
option_name str yes none Required positional or keyword input.

Returns

  • Type: Callable[[str], dict[str, Any]]
  • Direct return expressions: _parser

Exceptions and behavior

Function make_json_object_arg_parser returns _parser. No direct raise statement appears in this definition.

View source #L25-L31.

vllm_mlx.cli_arg_types.make_json_object_arg_parser._parser · nested function
vllm_mlx.cli_arg_types.make_json_object_arg_parser._parser(value: str) -> dict[str, Any]

Nested Function make_json_object_arg_parser._parser calls parse_json_object_arg; returns parse_json_object_arg(value, option_name).

Parameters

Name Type Required Default Description
value str yes none Required positional or keyword input.

Returns

  • Type: dict[str, Any]
  • Direct return expressions: parse_json_object_arg(value, option_name)

Exceptions and behavior

Nested Function make_json_object_arg_parser._parser calls parse_json_object_arg; returns parse_json_object_arg(value, option_name). No direct raise statement appears in this definition.

View source #L28-L29.

vllm_mlx.cli_arg_types.positive_int_arg · function
vllm_mlx.cli_arg_types.positive_int_arg(value: str) -> int

Parse an argparse integer that must be greater than zero.

Parameters

Name Type Required Default Description
value str yes none Required positional or keyword input.

Returns

  • Type: int
  • Direct return expressions: parsed

Exceptions and behavior

Function positive_int_arg calls int, argparse.ArgumentTypeError; can raise argparse.ArgumentTypeError; returns parsed. Directly raised exceptions: argparse.ArgumentTypeError.

View source #L34-L42.

vllm_mlx.cli_arg_types.parse_positive_int_arg · function
vllm_mlx.cli_arg_types.parse_positive_int_arg(value: str, option_name: str) -> int

Parse and validate that an option value is a positive integer.

Parameters

Name Type Required Default Description
value str yes none Required positional or keyword input.
option_name str yes none Required positional or keyword input.

Returns

  • Type: int
  • Direct return expressions: parsed

Exceptions and behavior

Function parse_positive_int_arg calls int, argparse.ArgumentTypeError; can raise argparse.ArgumentTypeError; returns parsed. Directly raised exceptions: argparse.ArgumentTypeError.

View source #L45-L53.

vllm_mlx.cli_arg_types.make_positive_int_arg_parser · function
vllm_mlx.cli_arg_types.make_positive_int_arg_parser(option_name: str) -> Callable[[str], int]

Create an argparse type parser for positive integer options.

Parameters

Name Type Required Default Description
option_name str yes none Required positional or keyword input.

Returns

  • Type: Callable[[str], int]
  • Direct return expressions: _parser

Exceptions and behavior

Function make_positive_int_arg_parser returns _parser. No direct raise statement appears in this definition.

View source #L56-L62.

vllm_mlx.cli_arg_types.make_positive_int_arg_parser._parser · nested function
vllm_mlx.cli_arg_types.make_positive_int_arg_parser._parser(value: str) -> int

Nested Function make_positive_int_arg_parser._parser calls parse_positive_int_arg; returns parse_positive_int_arg(value, option_name).

Parameters

Name Type Required Default Description
value str yes none Required positional or keyword input.

Returns

  • Type: int
  • Direct return expressions: parse_positive_int_arg(value, option_name)

Exceptions and behavior

Nested Function make_positive_int_arg_parser._parser calls parse_positive_int_arg; returns parse_positive_int_arg(value, option_name). No direct raise statement appears in this definition.

View source #L59-L60.

Complete symbol map

This map also includes private definitions and nested helpers. The signature column exposes every explicit input even when an internal helper has no dedicated parameter prose.

Symbol Kind Signature and inputs What it does Source
parse_json_object_arg function parse_json_object_arg(value: str, option_name: str) -> dict[str, Any] Parse and validate that an option value is a JSON object. #L10-L22
make_json_object_arg_parser function make_json_object_arg_parser(option_name: str) -> Callable[[str], dict[str, Any]] Create an argparse type parser for JSON object options. #L25-L31
make_json_object_arg_parser._parser nested function make_json_object_arg_parser._parser(value: str) -> dict[str, Any] Nested Function make_json_object_arg_parser._parser calls parse_json_object_arg; returns parse_json_object_arg(value, option_name). #L28-L29
positive_int_arg function positive_int_arg(value: str) -> int Parse an argparse integer that must be greater than zero. #L34-L42
parse_positive_int_arg function parse_positive_int_arg(value: str, option_name: str) -> int Parse and validate that an option value is a positive integer. #L45-L53
make_positive_int_arg_parser function make_positive_int_arg_parser(option_name: str) -> Callable[[str], int] Create an argparse type parser for positive integer options. #L56-L62
make_positive_int_arg_parser._parser nested function make_positive_int_arg_parser._parser(value: str) -> int Nested Function make_positive_int_arg_parser._parser calls parse_positive_int_arg; returns parse_positive_int_arg(value, option_name). #L59-L60