{"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":"python","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,"search_vec":"'5.0.2':50 'activ':42 'argument':56 'automat':25 'cli':27,51 'clis':16,23 'clize':1,2 'command':13,53 'command-lin':12,52 'comprehens':34 'creation':10 'current':46 'direct':18 'docstr':38 'function':21,30,57 'generat':33 'help':35 'infer':26 'interfac':15 'librari':6,40 'line':14,54 'maintain':43 'messag':36 'paramet':28 'parser':55 'python':5,20 'signatur':31 'simplifi':8 'stabl':47 'transform':19 'version':48","created_at":"2026-04-11T09:12:05.682710+00:00","updated_at":"2026-04-16T02:36:44.001144+00:00","problems":[{"fix":"Install clize using pip: `pip install clize`","cause":"The 'clize' library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'clize'"},{"fix":"Provide the missing positional argument when running the command, e.g., `python your_script.py 'hello'`.","cause":"A positional argument defined in the decorated function was not provided on the command line.","error":"Missing required arguments: word"},{"fix":"Ensure all command-line arguments correspond to the function's expected positional parameters, or define a parameter to collect extra arguments (e.g., `*args`).","cause":"The command line received more positional arguments than expected by the function signature.","error":"Received extra arguments: spam"},{"fix":"Provide an argument that can be correctly converted by the parameter's type, or explicitly define a converter for the parameter using type annotations, such as `param:int` or `param:converter_function`.","cause":"Clize attempted to convert a command-line argument (which is a string) to an expected Python type, but the default type converter could not handle the string input directly.","error":"TypeError: an integer is required (got type str)"},{"fix":"Upgrade pip and reinstall Clize: `pip install --upgrade pip` followed by `pip install clize --upgrade` to ensure all dependencies are installed.","cause":"A core dependency of Clize, such as 'sigtools', was not installed correctly or is missing from the environment.","error":"ImportError: No module named 'sigtools'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"5.0.2","cli_name":"clize","cli_version":"sh: 1: clize: not found","type":"library","homepage":null,"github":"https://github.com/epsy/clize","docs":null,"changelog":null,"pypi":"https://pypi.org/project/clize/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}