Skip to content

Commit e9d769e

Browse files
adding README
1 parent c0414e2 commit e9d769e

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
[![CI](https://github.com/andreascaglioni/python-project-template/actions/workflows/tests.yml/badge.svg)](https://github.com/andreascaglioni/python-project-template/actions/workflows/tests.yml)
2+
[![PyPI Version](https://img.shields.io/pypi/v/python-project-template.svg)](https://pypi.org/project/python-project-template/)
3+
[![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5+
6+
# python-project-template — showcasing good software practices
7+
A minimal Python project demonstrating best practices for testing, documentation, CI/CD, packaging, examples.
8+
The library provides a tiny Calculator API that can register and compose simple mathematical operations.
9+
10+
## Table of contents
11+
- [Features](#features)
12+
- [Installation](#installation)
13+
- [Quick usage](#quick-usage)
14+
- [Examples & experiments](#examples--experiments)
15+
- [Running tests](#running-tests)
16+
- [Project structure](#project-structure)
17+
- [Contributing](#contributing)
18+
- [License](#license)
19+
20+
## Features
21+
- Small, dependency-free core API: Operation, OperationRegistry, Calculator
22+
- Example operations (add, sub, mul, div, neg, sqr)
23+
- Utilities and clear error handling
24+
- Tests (pytest) and CI workflow included
25+
26+
## Installation
27+
28+
Clone the repository and create a virtual environment (recommended):
29+
30+
```bash
31+
git clone <repo-url>
32+
cd python-project-template
33+
python3 -m venv .venv
34+
source .venv/bin/activate
35+
python -m pip install --upgrade pip setuptools wheel
36+
pip install -e ".[dev]"
37+
```
38+
39+
This installs the package in editable mode and the development extras (pytest,
40+
pre-commit, formatting and linting tools) so you can run tests and linters.
41+
42+
## Quick usage
43+
44+
Interactive example using the package API:
45+
46+
```python
47+
from python_project_template import default_calculator, Operation
48+
49+
# Create a default calculator (pre-populated with common ops)
50+
calc = default_calculator()
51+
52+
# Apply an operation
53+
print(calc.apply('add', 2, 3)) # -> 5
54+
55+
# Compose unary operations
56+
f = calc.compose(['neg', 'sqr'])
57+
print(f(3)) # -> 9
58+
59+
# Register a custom operation
60+
def inc(x):
61+
return x + 1
62+
63+
calc.register(Operation('inc', inc, arity=1), replace=True)
64+
print(calc.apply('inc', 4)) # -> 5
65+
```
66+
67+
## Examples & experiments
68+
69+
- `experiments/` — short runnable demos. Each experiment should include a
70+
`README.md` explaining inputs and expected outputs.
71+
- `notebooks/` — exploratory notebooks (keep final versions small).
72+
73+
## Running tests
74+
75+
Run the full test suite with coverage:
76+
77+
```bash
78+
pytest -q --cov=python_project_template --cov-report=term --cov-report=html
79+
```
80+
81+
Open `htmlcov/index.html` to view the coverage report.
82+
83+
## Project structure
84+
85+
```
86+
src/python_project_template/ # library code
87+
- calculator.py # Calculator API
88+
- operations.py # Operation dataclass and example ops
89+
- registry.py # OperationRegistry
90+
- exceptions.py # custom exceptions
91+
- utils.py # small helpers
92+
experiments/ # short runnable demos
93+
notebooks/ # interactive exploration
94+
tests/ # pytest test suite
95+
docs/ # docs site (mkdocs)
96+
pyproject.toml # build & project config
97+
.github/workflows/ # CI workflows
98+
README.md
99+
LICENSE
100+
CITATION.cff
101+
```
102+
103+
## Contributing
104+
105+
Contributions are welcome. A quick workflow:
106+
107+
```bash
108+
git checkout -b feat/your-feature
109+
# make changes
110+
pytest # run tests locally
111+
git add -A && git commit -m "Add feature"
112+
git push --set-upstream origin feat/your-feature
113+
# open a PR
114+
```
115+
116+
### Developer notes
117+
- Use `pip install -e .[dev]` to get dev tools (pre-commit, black, ruff, mypy).
118+
- Run `pre-commit run --all-files` before committing.
119+
- CI runs tests on Ubuntu for Python 3.9–3.12 and uploads HTML coverage.
120+
121+
## License
122+
123+
This project is licensed under the MIT License — see the `LICENSE` file.
124+
125+
## Questions
126+
127+
If you have questions or want help extending the project (docs, CI, or
128+
examples), open an issue or drop a message in the repo.

0 commit comments

Comments
 (0)