infer-parser
infer-parser is a Python library for making shell argument parsers from type hints.
Install
pip install infer-parser
Example
import typing as t
from infer_parser import make_parser
parse = make_parser(t.Optional[int])
assert parse(["5"]) == 5
assert parse(["-11"]) == -11
assert parse([""]) is None
assert parse(["None"]) is None
try:
parse(["12.13"])
except ValueError:
print("not an Optional[int]")
parse_tuple = make_parser(tuple[float, ...])
assert parse_tuple(["1.5"]) == (1.5,)
assert parse_tuple(["0.0", "4.2", "-1"]) == (0.0, 4.2, -1.0)
assert parse_tuple([]) == ()
try:
parse(["Hello, world!"])
except ValueError:
print("not a tuple[float, ...]")
Limitations
infer-parser cannot always infer a parser.
import typing as t
from infer_parser import make_parser
try:
make_parser(t.Callable[..., int])
except TypeError:
print("not supported")
License
MIT.
Metadata
Release files for infer-parser 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| infer_parser-0.1.2.tar.gz | 7.5 kB | Without provenance | Details for infer_parser-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| infer_parser-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for infer_parser-0.1.2-py3-none-any.whl |
Total release size: 16.2 kB
Release files / infer_parser-0.1.2.tar.gz
| Download URL | infer_parser-0.1.2.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
72254d39e6a2550c906591ed9fd0e4e50e8c9dc70bfe137e10466c3229f777b6
|
|
BLAKE2b-256 checksum How to use checksums |
22a98483f9d43b07f33d4320826ab6582d869e3f2f745236a425480530bb84b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Release files / infer_parser-0.1.2-py3-none-any.whl
| Download URL | infer_parser-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ec67505547c48ed730d68c5e6c7b8b1863ca0e616ae6ca29c9c2a01430c52f8
|
|
BLAKE2b-256 checksum How to use checksums |
14ca41f5cedf9a0e3cd4d73709319afeee93340ae3e928a470d01b0914774332
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
|
Security for infer-parser 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.