[](https://badge.fury.io/py/typed-argparse)
[](https://github.com/typed-argparse/typed-argparse/actions?query=workflow%3Aci)
[](https://codecov.io/gh/typed-argparse/typed-argparse)
[](https://github.com/psf/black)
[](http://mypy-lang.org/)
[](LICENSE)
<br>
<img src="https://raw.githubusercontent.com/typed-argparse/typed-argparse/master/logo.svg" width="900">
<br>
💡 write type-safe and elegant CLIs with a clear separation of concerns.
<br>
<br>
## Features
- Argument parsing based on type annotation (including runtime validation).
- Support for many common types.
- Clear separation of concern between argument parsing and business logic.
- Support for super-low-latency shell auto-completions.
- Great for [writing sub-command CLIs](https://typed-argparse.github.io/typed-argparse/high_level_api/#sub-commands).
- Very lightweight.
- No dependencies.
- Fully typed itself, no extra type stubs required.
- Offers both a [high-level](https://typed-argparse.github.io/typed-argparse/high_level_api) and a [low-level](https://typed-argparse.github.io/typed-argparse/low_level_api) API.
The high-level API generally requires less code to write, is fully based on type annotations, and is the preferred way for writing new CLIs.
The low-level API is mainly a low-effort migration path for incorporating type-safety into existing CLIs based on `argparse`.
## Install
```console
$ pip install typed-argparse
```
The only requirement is a modern Python (3.8+).
## Basic Usage
```python
import typed_argparse as tap
# 1. Argument definition
class Args(tap.TypedArgs):
my_arg: str = tap.arg(help="some help")
number_a: int = tap.arg(default=42, help="some help")
number_b: Optional[int] = tap.arg(help="some help")
verbose: bool = tap.arg(help="some help")
names: List[str] = tap.arg(help="some help")
# 2. Business logic
def runner(args: Args):
print(f"Running my app with args:\n{args}")
# 3. Bind argument definition + business logic & run
def main() -> None:
tap.Parser(Args).bind(runner).run()
```
## Documentation
See [full documentation](https://typed-argparse.github.io/typed-argparse/).
## Changes
See [change log](CHANGES.md).
## License
This project is licensed under the terms of the [MIT license](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://typed-argparse.github.io/typed-argparse/",
"name": "typed-argparse",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "types",
"author": "Fabian Keller",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/18/74/2608ef98de41cd82743be47185048db93b4ff1bc59714666145de4376a1a/typed-argparse-0.3.1.tar.gz",
"platform": null,
"description": "[](https://badge.fury.io/py/typed-argparse)\n[](https://github.com/typed-argparse/typed-argparse/actions?query=workflow%3Aci)\n[](https://codecov.io/gh/typed-argparse/typed-argparse)\n[](https://github.com/psf/black)\n[](http://mypy-lang.org/)\n[](LICENSE)\n\n<br>\n\n<img src=\"https://raw.githubusercontent.com/typed-argparse/typed-argparse/master/logo.svg\" width=\"900\">\n\n<br>\n\ud83d\udca1 write type-safe and elegant CLIs with a clear separation of concerns.\n<br>\n<br>\n\n## Features\n\n- Argument parsing based on type annotation (including runtime validation).\n- Support for many common types.\n- Clear separation of concern between argument parsing and business logic.\n- Support for super-low-latency shell auto-completions.\n- Great for [writing sub-command CLIs](https://typed-argparse.github.io/typed-argparse/high_level_api/#sub-commands).\n- Very lightweight.\n- No dependencies.\n- Fully typed itself, no extra type stubs required.\n- Offers both a [high-level](https://typed-argparse.github.io/typed-argparse/high_level_api) and a [low-level](https://typed-argparse.github.io/typed-argparse/low_level_api) API.\n The high-level API generally requires less code to write, is fully based on type annotations, and is the preferred way for writing new CLIs.\n The low-level API is mainly a low-effort migration path for incorporating type-safety into existing CLIs based on `argparse`.\n\n\n## Install\n\n```console\n$ pip install typed-argparse\n```\n\nThe only requirement is a modern Python (3.8+).\n\n\n## Basic Usage\n\n```python\nimport typed_argparse as tap\n\n\n# 1. Argument definition\nclass Args(tap.TypedArgs):\n my_arg: str = tap.arg(help=\"some help\")\n number_a: int = tap.arg(default=42, help=\"some help\")\n number_b: Optional[int] = tap.arg(help=\"some help\")\n verbose: bool = tap.arg(help=\"some help\")\n names: List[str] = tap.arg(help=\"some help\")\n\n\n# 2. Business logic\ndef runner(args: Args):\n print(f\"Running my app with args:\\n{args}\")\n\n\n# 3. Bind argument definition + business logic & run\ndef main() -> None:\n tap.Parser(Args).bind(runner).run()\n```\n\n\n## Documentation\n\nSee [full documentation](https://typed-argparse.github.io/typed-argparse/).\n\n\n## Changes\n\nSee [change log](CHANGES.md).\n\n\n## License\n\nThis project is licensed under the terms of the [MIT license](LICENSE).\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Write type-safe and elegant CLIs with a clear separation of concerns.",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://typed-argparse.github.io/typed-argparse/",
"Source": "https://github.com/typed-argparse/typed-argparse"
},
"split_keywords": [
"types"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "53862217b32ee0f421ebf57df7ff898638eedfe2288aa6710dba2bca0607b689",
"md5": "ed8fe6952c7864d3ed8f4a856fbe2e82",
"sha256": "1fbbc3c6adde19aa04edafebd8a7efccab4ddd403d03ec68172cc20b237bbaa7"
},
"downloads": -1,
"filename": "typed_argparse-0.3.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ed8fe6952c7864d3ed8f4a856fbe2e82",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 19686,
"upload_time": "2023-09-25T20:40:18",
"upload_time_iso_8601": "2023-09-25T20:40:18.691579Z",
"url": "https://files.pythonhosted.org/packages/53/86/2217b32ee0f421ebf57df7ff898638eedfe2288aa6710dba2bca0607b689/typed_argparse-0.3.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "18742608ef98de41cd82743be47185048db93b4ff1bc59714666145de4376a1a",
"md5": "0bcc508912a4f3bf513e7bc323514c31",
"sha256": "3aac61caa50206e080d09a00c3fe552bc4e642739beaef89f5f8c1131b5d5afe"
},
"downloads": -1,
"filename": "typed-argparse-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "0bcc508912a4f3bf513e7bc323514c31",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 18394,
"upload_time": "2023-09-25T20:40:20",
"upload_time_iso_8601": "2023-09-25T20:40:20.337880Z",
"url": "https://files.pythonhosted.org/packages/18/74/2608ef98de41cd82743be47185048db93b4ff1bc59714666145de4376a1a/typed-argparse-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-25 20:40:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "typed-argparse",
"github_project": "typed-argparse",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "typed-argparse"
}