with-argparse


Namewith-argparse JSON
Version 0.0.6 PyPI version JSON
download
home_pageNone
SummaryA simple but handy Python library to generate a `argparse.ArgumentParser` object from a type-annotated method
upload_time2024-06-21 10:27:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseApache 2.0
keywords argparse type annotation auto
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # with-argparse

`with-argparse` is a very simple and tiny package adding support to create
and apply `argparse.ArgumentParser` objects automatically using the type 
annotations from a given python method:

```python3
from pathlib import Path
from with_argparse import with_argparse

@with_argparse
def sample_method(
    text_input: str,  # required argument
    another_text_input: str = None,  # default argument
    output_dir: Path = None,
    flag: bool = False,
):
    pass

sample_method()
```

will generate the argparse output:

```text
usage: scratch_2.py [-h] --text_input TEXT_INPUT
                    [--another_text_input ANOTHER_TEXT_INPUT]
                    [--output_dir OUTPUT_DIR] [--flag]
```

### Boolean values

- A `True` boolean default field `flag` is converted to `--no_flag`

### Configurability

- `with_opt_argparse` allows to override some of the default settings used

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "with-argparse",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "argparse, type annotation, auto",
    "author": null,
    "author_email": "Moritz Hennen <mail@fleance.de>",
    "download_url": "https://files.pythonhosted.org/packages/19/de/f6d479bb1c6c635232030f5fb439f15cc049512064c2597961693ac906a6/with_argparse-0.0.6.tar.gz",
    "platform": null,
    "description": "# with-argparse\n\n`with-argparse` is a very simple and tiny package adding support to create\nand apply `argparse.ArgumentParser` objects automatically using the type \nannotations from a given python method:\n\n```python3\nfrom pathlib import Path\nfrom with_argparse import with_argparse\n\n@with_argparse\ndef sample_method(\n    text_input: str,  # required argument\n    another_text_input: str = None,  # default argument\n    output_dir: Path = None,\n    flag: bool = False,\n):\n    pass\n\nsample_method()\n```\n\nwill generate the argparse output:\n\n```text\nusage: scratch_2.py [-h] --text_input TEXT_INPUT\n                    [--another_text_input ANOTHER_TEXT_INPUT]\n                    [--output_dir OUTPUT_DIR] [--flag]\n```\n\n### Boolean values\n\n- A `True` boolean default field `flag` is converted to `--no_flag`\n\n### Configurability\n\n- `with_opt_argparse` allows to override some of the default settings used\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "A simple but handy Python library to generate a `argparse.ArgumentParser` object from a type-annotated method",
    "version": "0.0.6",
    "project_urls": {
        "repository": "https://github.com/fleonce/with-argparse/"
    },
    "split_keywords": [
        "argparse",
        " type annotation",
        " auto"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e42d02d75ec9e82a2543375a5e343057b7949a213f34fc39492468568ef0dd0c",
                "md5": "036c187686d40a5f747337170b5bd0e8",
                "sha256": "0dd1c39f3ab146d780a93af47a4764ce4c3efb89b7eb8f222379e12f92ad7482"
            },
            "downloads": -1,
            "filename": "with_argparse-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "036c187686d40a5f747337170b5bd0e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7556,
            "upload_time": "2024-06-21T10:27:11",
            "upload_time_iso_8601": "2024-06-21T10:27:11.624173Z",
            "url": "https://files.pythonhosted.org/packages/e4/2d/02d75ec9e82a2543375a5e343057b7949a213f34fc39492468568ef0dd0c/with_argparse-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19def6d479bb1c6c635232030f5fb439f15cc049512064c2597961693ac906a6",
                "md5": "d0c567a30aa463737e25f313a6c83883",
                "sha256": "b6d29edb8a2fd8b1b874e19e3ec79aad4712f13a779857e6bde0bf201a848a7e"
            },
            "downloads": -1,
            "filename": "with_argparse-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "d0c567a30aa463737e25f313a6c83883",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7131,
            "upload_time": "2024-06-21T10:27:12",
            "upload_time_iso_8601": "2024-06-21T10:27:12.665084Z",
            "url": "https://files.pythonhosted.org/packages/19/de/f6d479bb1c6c635232030f5fb439f15cc049512064c2597961693ac906a6/with_argparse-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-21 10:27:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fleonce",
    "github_project": "with-argparse",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "with-argparse"
}
        
Elapsed time: 0.64340s