{"id":3401,"library":"argparse-addons","title":"argparse-addons","description":"argparse-addons is a Python library that provides additional types and actions for the standard library's `argparse` module, enhancing command-line interface creation. The current version is 0.12.0. The project maintains a somewhat active release cadence, with the last update in January 2023.","status":"active","version":"0.12.0","language":"python","source_language":"en","source_url":"https://github.com/eerimoq/argparse_addons","tags":["argparse","cli","command-line","utilities","types"],"install":[{"cmd":"pip install argparse-addons","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"Integer","correct":"from argparse_addons import Integer"}],"quickstart":{"code":"import argparse\nfrom argparse_addons import Integer\n\nparser = argparse.ArgumentParser(description='Process some integers.')\nparser.add_argument(\n    '--value', \n    type=Integer(0, 255), \n    help='An integer value between 0 and 255.'\n)\n\nargs = parser.parse_args(['--value', '128'])\nprint(f'Parsed value: {args.value}')\n\n# Example of invalid input (will raise an error during parse_args)\n# try:\n#     parser.parse_args(['--value', '-1'])\n# except SystemExit as e:\n#     print(f'Error: {e}')","lang":"python","description":"This quickstart demonstrates how to define an argument using the `Integer` type from `argparse-addons`, enforcing a value within a specified range. It uses a standard `argparse.ArgumentParser` instance."},"warnings":[{"fix":"Wrap `ArgumentParser` creation and `parse_args()` calls in `if __name__ == \"__main__\":`.","message":"Calling `parser.parse_args()` at the top level of an imported module can lead to unexpected argument parsing behavior or errors in the main script. Always guard `ArgumentParser` instantiation and `parse_args()` calls within an `if __name__ == \"__main__\":` block if the module is intended to be imported.","severity":"gotcha","affected_versions":"All versions of argparse-addons (inherent argparse behavior)"},{"fix":"Consider if `nargs='*'` is truly appropriate with `choices` for positional arguments, or explicitly add `[]` to your `choices` (though this might clutter help output). Alternatively, ensure a default is set that is within `choices`.","message":"When a positional argument is defined with `nargs='*'` (zero or more arguments) and also `choices`, providing no values for that argument can result in an 'invalid choice: []' error, because `argparse` attempts to validate an empty list against the defined choices.","severity":"gotcha","affected_versions":"All versions of argparse-addons (inherent argparse behavior)"},{"fix":"Avoid using `default` directly with `action='append'` or `action='extend'` if the intention is for the user's input to completely replace the default. Instead, handle default list population manually after `parse_args()`.","message":"The interaction between `default` values and actions like `action='append'` or `action='extend'` can be non-intuitive. Default values might be prepended to user-provided input, making it difficult to completely override the default without custom logic.","severity":"gotcha","affected_versions":"All versions of argparse-addons (inherent argparse behavior)"}],"env_vars":null,"search_vec":"'0.12.0':34 '2023':49 'action':16 'activ':40 'addit':13 'addon':3,6 'argpars':2,5,22,50 'argparse-addon':1,4 'cadenc':42 'cli':51 'command':26,53 'command-lin':25,52 'creation':29 'current':31 'enhanc':24 'interfac':28 'januari':48 'last':45 'librari':10,20 'line':27,54 'maintain':37 'modul':23 'project':36 'provid':12 'python':9 'releas':41 'somewhat':39 'standard':19 'type':14,56 'updat':46 'util':55 'version':32","created_at":"2026-04-11T17:26:33.200413+00:00","updated_at":"2026-04-15T20:57:42.281188+00:00","problems":[{"fix":"Install the module using pip: 'pip install argparse-addons'.","cause":"The 'argparse_addons' module is not installed or is installed incorrectly.","error":"ModuleNotFoundError: No module named 'argparse_addons'"},{"fix":"Convert the argument to an integer before comparison: 'if int(args.detect_mode) > 1:'.","cause":"Comparing a string argument to an integer without converting the string to an integer first.","error":"TypeError: '>' not supported between instances of 'str' and 'int'"},{"fix":"Ensure each argument has a unique option string in the ArgumentParser definition.","cause":"Defining two arguments with the same option string in argparse.","error":"argparse.ArgumentError: argument --foo: conflicting option string: --foo"},{"fix":"Ensure that the value provided for the argument is a valid integer.","cause":"Providing a non-integer value for an argument expected to be an integer.","error":"argparse.ArgumentTypeError: invalid int value: 'net_model'"},{"fix":"Upgrade to Python 3.6 or later, or use an alternative string formatting method.","cause":"Using f-string syntax in a Python version that does not support it.","error":"SyntaxError: invalid syntax"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.12.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/eerimoq/argparse_addons","docs":null,"changelog":null,"pypi":"https://pypi.org/project/argparse-addons/","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-29","next_check":"2026-07-28","install_tag":null}}