arghelper
arghelper is a Python 3.12+ module providing functions to help with argparse.
Installation
You can install arghelper either via the Python Package Index (PyPI) or from source.
To add it to a project managed with uv, which records it in your
pyproject.toml and lock file:
$ uv add arghelper
Or to install it with pip:
$ pip install arghelper
Source: https://github.com/questrail/arghelper
Requirements
argparsemodule from the Python Standard Libraryosmodule from the Python Standard Library
Usage
arghelper provides functions to determine if a file or directory
exists:
extant_fileextant_dir
These can be used as follows:
if __name__ == "__main__":
# Process the arguments
import argparse
import arghelper
parser = argparse.ArgumentParser(description="Process the TAFFmat CET files")
parser.add_argument(
"config_file",
help="CSV configuration file.",
metavar="FILE",
type=arghelper.extant_file,
)
parser.add_argument(
"input_dir",
help="Directory containing input files.",
metavar="DIR",
type=arghelper.extant_dir,
)
args = parser.parse_args()
A common pattern, for me at least, is to have three positional arguments consisting of:
config_file--- A configuration fileinput_dir--- A directory containing input files to be readoutput_dir--- A directory where the output files should be saved
This pattern has been abstracted to a Facade function called
parse_config_input_output, which can be used as follows:
if __name__ == "__main__":
# Process the arguments
import sys
import arghelper
args = arghelper.parse_config_input_output(sys.argv)
Another common pattern is to just parse the name of a config file:
if __name__ == "__main__":
# Process the arguments
import sys
import arghelper
args = arghelper.parse_config(sys.argv)
Contributing
Contributions are welcome! To contribute please:
- Fork the repository
- Create a feature branch
- Add code and tests
- Pass lint and tests
- Submit a pull request
Development Setup
arghelper uses uv to manage the virtualenv and dependencies, and just as the task runner.
$ brew install uv just
uv sync creates the virtualenv and installs the dependencies, including
the development group, and just on its own lists the available recipes.
$ uv sync
$ just
The most common recipes are:
$ just test # Run the tests using pytest
$ just lint # Check lint, formatting, types, and workflows
$ just fix # Lint and format the code using ruff, applying fixes
$ just cov # Run the tests and report coverage
$ just add X # Add X as a dependency
$ just out # List the outdated dependencies
ruff and pyright are deliberately absent from that brew install
line. Both are dev dependencies pinned in uv.lock and reached through uv run, so every recipe and every CI job uses the same version. A brew install ruff would put a second, unpinned copy on the path for an editor
to find, and ruff releases change how code is formatted: the editor would
then reformat code that ruff format --check rejects on the next run.
The suite runs on 3.12, 3.13, and 3.14 in CI, which is what
requires-python and the classifiers claim.
Releasing to PyPI
just release cuts the release. It first checks that a release is possible
at all, then lints, type checks, and tests, then shows the entries waiting
under Unreleased and the version each kind of bump would produce, and asks
which to cut. Once answered it bumps the version, closes out the CHANGELOG,
updates the lock file, commits, and tags. Pushing the tag is what publishes.
$ just release
...
Which release? [1] 1
Tagged v0.6.1. Publish it with:
git push --follow-tags
Do not tag by hand. The tag push runs the release workflow, which waits
on the whole CI workflow before it does anything else. It then
checks that the tagged commit is on master, since a tag is only a pointer
and one placed anywhere else would otherwise publish whatever it points at,
rechecks the tag against the version in pyproject.toml, and builds.
Every check to that point runs against the source tree, so the workflow
then installs the wheel it just built somewhere src/ is not on the path
and exercises it there, which is the only step that can catch a packaging
mistake. It uploads once that passes. There is no PyPI API token anywhere:
the workflow authenticates with trusted publishing, which mints a short
lived credential from the GitHub OIDC identity of that run, and that same
identity signs a PEP 740 attestation for each distribution.
Uploading is followed by a GitHub release for the tag, carrying the CHANGELOG section for that version as its notes.
Pushing the tag is the point of no return, since PyPI never lets a version
number be reused. Everything just release does is local and amendable
until then, and it refuses to start against a dirty working tree, off
master, on a master behind its upstream, with a CHANGELOG whose
Unreleased section is empty, or when the tag it would create already
exists. just release-check runs those refusals on their own.
just build runs the same checks and produces the same distributions
without releasing anything.
This depends on one piece of configuration that lives outside the
repository. A trusted publisher has to be registered
for arghelper on PyPI, pointing at the questrail/arghelper repository,
the release.yml workflow, and the pypi environment. It is a one time
setup per project.
License
arghelper is released under the MIT license. Please see the LICENSE.txt file for more information.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arghelper-0.8.0.tar.gz.
File metadata
- Download URL: arghelper-0.8.0.tar.gz
- Upload date:
- Size: 36.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd39fa2cabfb591c546579dcd9ac2f5b39723299a990714a3df06679df2db26b
|
|
| MD5 |
12bfe826fc8c72c7f06669ac0aff7921
|
|
| BLAKE2b-256 |
563eb2dadc97177683ca3b55a0fa6cfe8d12f212fa993eddb10160622d4230ef
|
Provenance
The following attestation bundles were made for arghelper-0.8.0.tar.gz:
Publisher:
release.yml on questrail/arghelper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arghelper-0.8.0.tar.gz -
Subject digest:
dd39fa2cabfb591c546579dcd9ac2f5b39723299a990714a3df06679df2db26b - Sigstore transparency entry: 2679021350
- Sigstore integration time:
-
Permalink:
questrail/arghelper@31a8559f541995f46710e20524e43c756515ba4f -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/questrail
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@31a8559f541995f46710e20524e43c756515ba4f -
Trigger Event:
push
-
Statement type:
File details
Details for the file arghelper-0.8.0-py3-none-any.whl.
File metadata
- Download URL: arghelper-0.8.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f013fe2d324ae10acac30c2d490f9139a007c9321c51590e5ed56660908d876
|
|
| MD5 |
f278ba4c62796eb8f78099a62d986909
|
|
| BLAKE2b-256 |
a4ad2872af5f3fe884bf9b9be4a5ef81a88b971c1bfd6e6b9488e152e67d476a
|
Provenance
The following attestation bundles were made for arghelper-0.8.0-py3-none-any.whl:
Publisher:
release.yml on questrail/arghelper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arghelper-0.8.0-py3-none-any.whl -
Subject digest:
7f013fe2d324ae10acac30c2d490f9139a007c9321c51590e5ed56660908d876 - Sigstore transparency entry: 2679021444
- Sigstore integration time:
-
Permalink:
questrail/arghelper@31a8559f541995f46710e20524e43c756515ba4f -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/questrail
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@31a8559f541995f46710e20524e43c756515ba4f -
Trigger Event:
push
-
Statement type: