{"id":2892,"library":"clize","title":"Clize","description":"Clize is a Python library that simplifies the creation of command-line interfaces (CLIs) by directly transforming Python functions into CLIs. It automatically infers CLI parameters from function signatures and generates comprehensive `--help` messages from docstrings. The library is actively maintained, with the current stable version being 5.0.2.","status":"active","version":"5.0.2","language":"en","source_language":"en","source_url":"https://github.com/epsy/clize","tags":["cli","command-line","parser","arguments","functions"],"install":[{"cmd":"pip install clize","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for using `clize.converters.datetime` for date parsing.","package":"python-dateutil","optional":true}],"imports":[{"note":"The primary entry point for turning a function into a command-line interface.","symbol":"run","correct":"from clize import run"},{"note":"Used for advanced parameter annotations like `Parameter.cli_default`.","symbol":"Parameter","correct":"from clize import Parameter"}],"quickstart":{"code":"from clize import run\n\ndef hello(name: str = 'world', *, capitalize: bool = False):\n    \"\"\"Greets the world or a specific person.\n\n    :param name: The name to greet.\n    :param capitalize: Whether to capitalize the name.\n    \"\"\"\n    if capitalize:\n        name = name.title()\n    print(f\"Hello, {name}!\")\n\n\nif __name__ == '__main__':\n    run(hello)","lang":"python","description":"This example demonstrates how to create a simple CLI using `clize.run`. It defines a function `hello` with a positional argument `name` and a keyword-only argument `capitalize`. Running this script from the command line will automatically generate a CLI, including a `--help` message from the docstring."},"warnings":[{"fix":"Review usage of `bytes` annotations in function parameters and adjust expectations or encoding/decoding logic if necessary.","message":"The `bytes` annotation (converter) now re-encodes the corresponding parameter back to bytes, changing its behavior from previous versions.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Replace `convert_default` with `clize.Parameter.cli_default` for specifying default values that are converted by CLI value converters.","message":"The `convert_default` argument to `clize.parser.value_converter` is deprecated. Its functionality should now be handled via `clize.Parameter.cli_default`.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Set mutable default arguments to `None` and initialize the mutable object inside the function if `None` is detected (e.g., `if my_list is None: my_list = []`).","message":"Using mutable objects (e.g., lists, dictionaries) as default arguments in Python functions passed to `clize.run` can lead to unexpected shared state. Python evaluates default arguments once when the function is defined, not on each call.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to `clize` version 5.0.1 or newer if you are using `alt=` with a dictionary to define alternate commands.","message":"Prior to v5.0.1, using a dictionary in the `alt=` parameter of `clize.run` did not work correctly.","severity":"gotcha","affected_versions":"<5.0.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}