{"id":6478,"library":"typed-argument-parser","title":"Typed Argument Parser (Tap)","description":"Typed Argument Parser (Tap) is a Python library that modernizes `argparse` by leveraging type hints for command-line argument parsing. It offers benefits like static type checking, code completion, and improved source code navigation. Additionally, it provides `tapify`, a function inspired by Google's Python Fire, to effortlessly run functions or initialize classes directly from command-line arguments while automatically handling type conversions. Currently at version 1.12.0, Tap is actively developed with a regular release cadence, supporting Python 3.10 and newer.","status":"active","version":"1.12.0","language":"python","source_language":"en","source_url":"https://github.com/swansonk14/typed-argument-parser","tags":["argument parser","cli","type hints","argparse","pydantic","developer tools"],"install":[{"cmd":"pip install typed-argument-parser","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Required for parsing docstrings to generate help messages.","package":"docstring-parser","optional":false},{"reason":"Used for runtime inspection of type hints.","package":"typing-inspect","optional":false},{"reason":"Optional, for using `tapify` with Pydantic models (introduced in v1.10.0).","package":"pydantic","optional":true}],"imports":[{"symbol":"Tap","correct":"from tap import Tap"},{"symbol":"tapify","correct":"from tap import tapify"},{"note":"Used to mark class attributes that should not be parsed as command-line arguments (introduced in v1.12.0).","symbol":"TapIgnore","correct":"from tap import TapIgnore"},{"note":"Used to mark class attributes that should be parsed as positional command-line arguments (introduced in v1.12.0).","symbol":"Positional","correct":"from tap import Positional"}],"quickstart":{"code":"from tap import Tap\n\nclass SimpleArgumentParser(Tap):\n    name: str # Your name\n    language: str = 'Python' # Programming language\n    package: str = 'Tap' # Package name\n    stars: int # Number of stars\n    max_stars: int = 5 # Maximum stars\n\nif __name__ == '__main__':\n    args = SimpleArgumentParser().parse_args()\n    print(f'My name is {args.name} and I give the {args.language} package '\n          f'{args.package} {args.stars}/{args.max_stars} stars!')","lang":"python","description":"This example demonstrates defining a `Tap` class with typed arguments, including required and optional arguments with default values. The arguments are then parsed from the command line and used in the program."},"warnings":[{"fix":"Upgrade Python to 3.10+ or downgrade `typed-argument-parser` to `<1.12.0`.","message":"Version 1.12.0 (and newer) drops support for Python 3.9. Users on Python 3.9 must upgrade their Python version to 3.10 or newer, or pin `typed-argument-parser` to an older version.","severity":"breaking","affected_versions":">=1.12.0"},{"fix":"Ensure build systems are compatible with `pyproject.toml` and direct filesystem paths to `tap` are updated if used.","message":"Version 1.10.1 refactored the project structure, moving code from `tap/` to `src/tap` and `setup.py` to `pyproject.toml`. While direct imports are generally unaffected (`from tap import ...`), this might impact users with custom build systems or those relying on internal package structure.","severity":"breaking","affected_versions":">=1.10.1"},{"fix":"Pass `known_only=True` to `tapify` if your command-line interface should gracefully ignore unrecognized arguments.","message":"When using `tapify` to run functions or initialize classes, by default it will raise an error if additional, unneeded arguments are provided on the command line. To ignore extra arguments, use `known_only=True`.","severity":"gotcha","affected_versions":">=1.8.0"},{"fix":"If reproducibility info needs to come from a specific git repo, explicitly set the `repo_path` parameter in the `save` method.","message":"The behavior for handling reproducibility information's `repo_path` changed in v1.7.1. By default, it now uses the git repository of the directory containing the executed file, rather than the current working directory.","severity":"gotcha","affected_versions":">=1.7.1"},{"fix":"Be aware of the implicit boolean flag behavior. For explicit boolean parsing, call `parse_args(explicit_bool=True)`.","message":"Boolean arguments (e.g., `arg: bool = False`) are set to `True` by merely including the `--arg` flag. If `arg: bool = True`, `--arg` sets it to `False`. For explicit `True`/`False` values on the command line (e.g., `--arg True`), `explicit_bool=True` must be passed to `parse_args()`.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.12.0':73 '3.10':85 'activ':76 'addit':40 'argpars':15,93 'argument':2,6,24,64,88 'automat':66 'benefit':28 'cadenc':82 'check':32 'class':58 'cli':90 'code':33,38 'command':22,62 'command-lin':21,61 'complet':34 'convers':69 'current':70 'develop':77,95 'direct':59 'effortless':53 'fire':51 'function':45,55 'googl':48 'handl':67 'hint':19,92 'improv':36 'initi':57 'inspir':46 'leverag':17 'librari':12 'like':29 'line':23,63 'modern':14 'navig':39 'newer':87 'offer':27 'pars':25 'parser':3,7,89 'provid':42 'pydant':94 'python':11,50,84 'regular':80 'releas':81 'run':54 'sourc':37 'static':30 'support':83 'tap':4,8,74 'tapifi':43 'tool':96 'type':1,5,18,31,68,91 'version':72","created_at":"2026-04-15T05:39:03.324187+00:00","updated_at":"2026-04-16T23:24:21.942052+00:00","problems":[{"fix":"Change the import statement from `import typed_argument_parser` or `from typed_argument_parser import Tap` to `from tap import Tap` or `from tap import tapify`.","cause":"The user is attempting to import the library using its PyPI package name (`typed_argument_parser`) instead of its actual Python module name (`tap`).","error":"ModuleNotFoundError: No module named 'typed_argument_parser'"},{"fix":"Ensure all required arguments for the class's `__init__` method are either provided via command-line arguments (e.g., `--arg_name value`) or have default values defined in the class or `Tap` subclass.","cause":"A class used with `tapify` or as a `Tap` subclass has a constructor (`__init__`) with required arguments that are not provided through the command line and also lack default values.","error":"TypeError: __init__ missing 1 required positional argument: 'arg_name'"},{"fix":"Provide command-line arguments with values that are compatible with their specified type hints (e.g., use `--age 25` for an `int` argument, not `--age twenty-five`).","cause":"A command-line argument was provided with a value that cannot be successfully converted into the type specified by the corresponding type hint in the `Tap` class.","error":"ValueError: invalid literal for int() with base 10: 'abc'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.12.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/swansonk14/typed-argument-parser","docs":null,"changelog":null,"pypi":"https://pypi.org/project/typed-argument-parser/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}