Registry / http-networking / argparse-ext

argparse-ext

JSON →
library1.4.2pypypi✓ verified 83d ago

argparse-ext is a Python library that extends the standard `argparse` module, providing additional argument types and features for command-line interface parsing. It offers types like path, URL, JSON, email, and utilities for subcommands and config files. The current version is 1.4.2, and it maintains a steady, though not rapid, release cadence.

pip install argparse-ext
INSTALL
IMPORT
SIG · ARGPARSE-EXT
A
argparse-ext
http-networkingpythonv1.4.2
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HelpFormatter
from argparse_ext import HelpFormatter
from argparse_ext import ArgumentParser
RawDescriptionHelpFormatter
from argparse_ext import RawDescriptionHelpFormatter
from argparse_ext import ArgumentParser
argparse
from argparse_ext import argparse
from argparse_ext import ArgumentParser

This quickstart demonstrates how to import and use `argparse_ext.ArgumentParser` with some of its extended types like 'path', 'url', and 'json'. It also shows how to access the methods and attributes of the resulting parsed objects.

from argparse_ext import ArgumentParser parser = ArgumentParser(prog='my_cli_tool') parser.add_argument('--path', type='path', help='A path argument which becomes a pathlib.Path object') parser.add_argument('--url', type='url', help='A URL argument which becomes a urllib.parse.ParseResult object') parser.add_argument('--config', type='json', help='A JSON string which is parsed into a Python object') args = parser.parse_args(['--path', '/tmp/foo.txt', '--url', 'http://example.com/foo', '--config', '{"key": "value"}']) # Simulate args for quickstart print(f"Path object type: {type(args.path)}, absolute: {args.path.absolute()}") print(f"URL object type: {type(args.url)}, scheme: {args.url.scheme}") print(f"Config object type: {type(args.config)}, value: {args.config['key']}")
Debug
Known issues
gotchaEnsure you use `argparse_ext.ArgumentParser` when utilizing extended argument types (e.g., `type='path'`, `type='url'`). Standard `argparse.ArgumentParser` does not recognize these custom types and will raise a `ValueError`.
fix
Replace `from argparse import ArgumentParser` with `from argparse_ext import ArgumentParser` at the top of your script.
affects: All versions
gotchaExtended types parse arguments into specific Python objects, not just strings. For example, `type='path'` becomes a `pathlib.Path` object, and `type='url'` becomes a `urllib.parse.ParseResult` object. Do not assume they remain simple strings.
fix
Consult the argparse-ext documentation for each extended type to understand its resolved object type and access its specific methods/attributes (e.g., `args.path.absolute()` or `args.url.scheme`).
affects: All versions
gotchaWhen using `add_subcommand`, ensure that the subcommand name does not conflict with any existing arguments or built-in methods of the `ArgumentParser`. While rare, such conflicts can lead to unexpected parsing behavior or errors.
fix
Choose distinct subcommand names. If issues arise, explicitly check `args.command_name` (or whatever destination you set) for the subcommand that was parsed.
affects: All versions
Upgrade
Version history
1.4.2latest on PyPI · released Dec 25, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
argparse-ext — pip install argparse-ext · libregistry