python-project-template — showcasing good software practices
python-project-template is a small python project to showcase good programming and software practices such as testing, documentation, CI/CD.
This project implements a small dependence-free Calculator API (Operation, OperationRegistry, Calculator) that can register and compose simple mathematical operations.
Table of contents
Features Highlights
- Type-annotated API with runtime argument validation.
- Custom exceptions for clear error reporting.
- Comprehensive unit tests using
pytest. - Google-style documentation auto-generated with Sphinx.
- Pre-commit checks and code formatting tools.
- CI/CD pipelines for testing and docs via GitHub Actions.
See the Documentation for a detailed list of features.
Installation
To install the latest release from PyPI, use:
pip install python-project-template-AS
Alternatively, you can clone the repository and install dependencies and an editable installation of python-project-template-AS with:
git clone <https://github.com/andreascaglioni/python-project-template-AS>
cd python-project-template
pip install -e ".[dev]"
Usage and Testing
The following is a quick example for the Calculator API.
from python_project_template_AS import default_calculator, Operation
# Create a default calculator (pre-populated with common operations)
calc = default_calculator()
# Apply an addition operation
print(calc.apply('add', 2, 3)) # -> 5
# Compose unary operations into a Callable
f = calc.compose(['neg', 'sqr'])
print(f(-3)) # -> 9
# Register a custom operation
def inc(x):
return x + 1
calc.register(Operation('inc', inc, arity=1), replace=True)
print(calc.apply('inc', 4)) # -> 5
Find more examples in examples/.
To run the tests:
pytest tests/
pytest -v tests/ # verbose output
pytest --cov=python_project_template_AS tests/ # show test coverage
Documentation
For detailed documentation, please visit our GitHub Pages.
Contributing
Contributions are welcome. Typical workflow:
git checkout -b feat/your-feature
# make changes
pytest # run tests locally
git add -A && git commit -m "Add feature"
git push --set-upstream origin feat/your-feature
# open a PR
Run pip install -e .[dev] to get development tools (pre-commit, black, ruff, mypy, pytest, ...).
Run the pre-commit routine with pre-commit run --all-files before committing.
License
This project is licensed under the MIT License — see the LICENSE file.
Questions
If you have questions or want help extending the project (docs, CI, or examples), open an issue or drop a message in the repository.
Metadata
Release files for python-project-template-AS 0.1.3
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 | |
|---|---|---|---|---|
| python_project_template_as-0.1.3.tar.gz | 15.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_project_template_as-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.0 kB
Release files / python_project_template_as-0.1.3.tar.gz
| Download URL | python_project_template_as-0.1.3.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e6b9b988df95e8aeb928f972ef4fa9066ac935e462b7b7cd2d75153bec7341c
|
|
BLAKE2b-256 checksum How to use checksums |
5541f72803624da813aac437a575f8831a43ae674cac63708986bd66579576d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / python_project_template_as-0.1.3-py3-none-any.whl
| Download URL | python_project_template_as-0.1.3-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef3666c9fbeaaccfb9a0a11fba04879aba87a5a0e8459a58d49f389b9bce3297
|
|
BLAKE2b-256 checksum How to use checksums |
83d385f00bccd47cc74a3f9d1f27cd8fbd6071f8f455aeecf11dc651819aeece
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for python-project-template-AS 0.1.3
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.