test-python-package-release 0.5.0__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- """Test Python package release — template library."""
1
+ """Template library demonstrating Python package release CI/CD."""
2
2
 
3
- __version__ = "0.5.0" # managed by release-please
3
+ __version__ = "0.6.0" # managed by release-please
4
4
 
5
5
  from test_python_package_release.calculator import (
6
6
  add,
@@ -1,38 +1,178 @@
1
+ """Basic arithmetic operations."""
2
+
3
+
1
4
  def add(a: float, b: float) -> float:
5
+ """Add two numbers.
6
+
7
+ Args:
8
+ a: First addend.
9
+ b: Second addend.
10
+
11
+ Returns:
12
+ The sum of ``a`` and ``b``.
13
+
14
+ Examples:
15
+ >>> add(2, 3)
16
+ 5
17
+ >>> add(0.5, 0.25)
18
+ 0.75
19
+ """
2
20
  return a + b
3
21
 
4
22
 
5
23
  def subtract(a: float, b: float) -> float:
24
+ """Subtract one number from another.
25
+
26
+ Args:
27
+ a: Minuend.
28
+ b: Subtrahend.
29
+
30
+ Returns:
31
+ The difference ``a - b``.
32
+
33
+ Examples:
34
+ >>> subtract(5, 3)
35
+ 2
36
+ >>> subtract(0.5, 1)
37
+ -0.5
38
+ """
6
39
  return a - b
7
40
 
8
41
 
9
42
  def multiply(a: float, b: float) -> float:
43
+ """Multiply two numbers.
44
+
45
+ Args:
46
+ a: First factor.
47
+ b: Second factor.
48
+
49
+ Returns:
50
+ The product of ``a`` and ``b``.
51
+
52
+ Examples:
53
+ >>> multiply(4, 3)
54
+ 12
55
+ >>> multiply(2.5, 2)
56
+ 5.0
57
+ """
10
58
  return a * b
11
59
 
12
60
 
13
61
  def divide(a: float, b: float) -> float:
62
+ """Divide one number by another.
63
+
64
+ Args:
65
+ a: Dividend.
66
+ b: Divisor.
67
+
68
+ Returns:
69
+ The quotient of ``a`` and ``b``.
70
+
71
+ Raises:
72
+ ZeroDivisionError: If ``b`` is zero.
73
+
74
+ Examples:
75
+ >>> divide(6, 3)
76
+ 2.0
77
+ >>> divide(1, 0)
78
+ Traceback (most recent call last):
79
+ ...
80
+ ZeroDivisionError: Cannot divide by zero
81
+ """
14
82
  if b == 0:
15
83
  raise ZeroDivisionError("Cannot divide by zero")
16
84
  return a / b
17
85
 
18
86
 
19
87
  def power(base: float, exponent: float) -> float:
88
+ """Raise a number to a power.
89
+
90
+ Args:
91
+ base: The base value.
92
+ exponent: The exponent.
93
+
94
+ Returns:
95
+ ``base`` raised to the power of ``exponent``.
96
+
97
+ Examples:
98
+ >>> power(2, 3)
99
+ 8
100
+ >>> power(2, -1)
101
+ 0.5
102
+ """
20
103
  return base**exponent
21
104
 
22
105
 
23
106
  def modulo(a: float, b: float) -> float:
107
+ """Compute the remainder of a division.
108
+
109
+ Args:
110
+ a: Dividend.
111
+ b: Divisor.
112
+
113
+ Returns:
114
+ The remainder of ``a`` divided by ``b``.
115
+
116
+ Raises:
117
+ ZeroDivisionError: If ``b`` is zero.
118
+
119
+ Examples:
120
+ >>> modulo(7, 3)
121
+ 1
122
+ >>> modulo(1, 0)
123
+ Traceback (most recent call last):
124
+ ...
125
+ ZeroDivisionError: Cannot modulo by zero
126
+ """
24
127
  if b == 0:
25
128
  raise ZeroDivisionError("Cannot modulo by zero")
26
129
  return a % b
27
130
 
28
131
 
29
132
  def sqrt(x: float) -> float:
133
+ """Compute the square root of a number.
134
+
135
+ Args:
136
+ x: A non-negative number.
137
+
138
+ Returns:
139
+ The square root of ``x``.
140
+
141
+ Raises:
142
+ ValueError: If ``x`` is negative.
143
+
144
+ Examples:
145
+ >>> sqrt(9)
146
+ 3.0
147
+ >>> sqrt(-1)
148
+ Traceback (most recent call last):
149
+ ...
150
+ ValueError: Cannot take square root of a negative number
151
+ """
30
152
  if x < 0:
31
153
  raise ValueError("Cannot take square root of a negative number")
32
154
  return x**0.5
33
155
 
34
156
 
35
157
  def is_divisible(a: float, b: float) -> bool:
158
+ """Check whether one number is evenly divisible by another.
159
+
160
+ Args:
161
+ a: Dividend.
162
+ b: Divisor.
163
+
164
+ Returns:
165
+ True if ``a`` is divisible by ``b`` with no remainder, otherwise False.
166
+
167
+ Raises:
168
+ ZeroDivisionError: If ``b`` is zero.
169
+
170
+ Examples:
171
+ >>> is_divisible(10, 5)
172
+ True
173
+ >>> is_divisible(10, 3)
174
+ False
175
+ """
36
176
  if b == 0:
37
177
  raise ZeroDivisionError("Cannot divide by zero")
38
178
  return a % b == 0
@@ -1,17 +1,70 @@
1
+ """String manipulation helpers."""
2
+
3
+
1
4
  def reverse_string(s: str) -> str:
5
+ """Reverse a string.
6
+
7
+ Args:
8
+ s: The string to reverse.
9
+
10
+ Returns:
11
+ The characters of ``s`` in reverse order.
12
+
13
+ Examples:
14
+ >>> reverse_string("hello")
15
+ 'olleh'
16
+ """
2
17
  return s[::-1]
3
18
 
4
19
 
5
20
  def snake_to_camel(s: str) -> str:
21
+ """Convert a snake_case string to camelCase.
22
+
23
+ Args:
24
+ s: A string in snake_case.
25
+
26
+ Returns:
27
+ The string in camelCase.
28
+
29
+ Examples:
30
+ >>> snake_to_camel("hello_world")
31
+ 'helloWorld'
32
+ """
6
33
  parts = s.split("_")
7
34
  return parts[0] + "".join(p.title() for p in parts[1:])
8
35
 
9
36
 
10
37
  def count_words(s: str) -> int:
38
+ """Count the words in a string.
39
+
40
+ Args:
41
+ s: The text to inspect. Words are separated by whitespace.
42
+
43
+ Returns:
44
+ The number of words, or 0 for an empty or whitespace-only string.
45
+
46
+ Examples:
47
+ >>> count_words(" hello world ")
48
+ 2
49
+ >>> count_words(" ")
50
+ 0
51
+ """
11
52
  return len(s.split()) if s.strip() else 0
12
53
 
13
54
 
14
55
  def camel_to_snake(s: str) -> str:
56
+ """Convert a camelCase string to snake_case.
57
+
58
+ Args:
59
+ s: A string in camelCase.
60
+
61
+ Returns:
62
+ The string in snake_case.
63
+
64
+ Examples:
65
+ >>> camel_to_snake("helloWorld")
66
+ 'hello_world'
67
+ """
15
68
  result = []
16
69
  for i, ch in enumerate(s):
17
70
  if ch.isupper() and i > 0:
@@ -21,6 +74,22 @@ def camel_to_snake(s: str) -> str:
21
74
 
22
75
 
23
76
  def truncate(s: str, max_length: int, suffix: str = "...") -> str:
77
+ """Truncate a string to a maximum length.
78
+
79
+ Args:
80
+ s: The string to truncate.
81
+ max_length: Maximum length of the result, including the suffix.
82
+ suffix: Text appended when truncation occurs.
83
+
84
+ Returns:
85
+ ``s`` unchanged if it fits, otherwise a shortened string ending with ``suffix``.
86
+
87
+ Examples:
88
+ >>> truncate("Hello, world!", 8)
89
+ 'Hello...'
90
+ >>> truncate("short", 10)
91
+ 'short'
92
+ """
24
93
  if len(s) <= max_length:
25
94
  return s
26
95
  return s[: max_length - len(suffix)] + suffix
@@ -1,7 +1,11 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: test-python-package-release
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Template library demonstrating Python package release CI/CD
5
+ Project-URL: Homepage, https://github.com/wozniakos10/test_python_package_release
6
+ Project-URL: Documentation, https://wozniakos10.github.io/test_python_package_release/
7
+ Project-URL: Repository, https://github.com/wozniakos10/test_python_package_release
8
+ Project-URL: Changelog, https://github.com/wozniakos10/test_python_package_release/blob/main/CHANGELOG.md
5
9
  Author-email: Dawid Wozniak <wozniakos10@gmail.com>
6
10
  License: MIT License
7
11
 
@@ -37,6 +41,8 @@ Description-Content-Type: text/markdown
37
41
  Template repository demonstrating a complete CI/CD pipeline for Python packages
38
42
  published to PyPI.
39
43
 
44
+ **Documentation:** https://wozniakos10.github.io/test_python_package_release/
45
+
40
46
  ## Quick start
41
47
 
42
48
  ```bash
@@ -48,9 +54,12 @@ uv run pytest
48
54
 
49
55
  ```
50
56
  .
51
- ├── .github/workflows/ # CI, Claude review, release-please, publish
57
+ ├── .github/workflows/ # CI, Claude review, release-please, publish, docker, docs
52
58
  ├── src/ # library code (src/ layout)
53
59
  ├── tests/ # pytest tests
60
+ ├── docs/ # documentation pages (Markdown)
61
+ ├── zensical.toml # documentation site config
62
+ ├── Dockerfile
54
63
  ├── pyproject.toml # single source of truth: build, deps, ruff, pytest, tox
55
64
  ├── .pre-commit-config.yaml
56
65
  ├── commitlint.config.cjs
@@ -65,14 +74,15 @@ configured in `pyproject.toml` (no scattered config files).
65
74
  | Tool | Purpose | Where it runs |
66
75
  |---|---|---|
67
76
  | [**uv**](https://docs.astral.sh/uv/) | Package manager, virtualenv handler, Python installer, build tool. Replaces `pip` + `venv` + `pip-tools` + `pyenv`. | Local + CI |
68
- | [**ruff**](https://docs.astral.sh/ruff/) | Linter + formatter (replaces flake8, isort, black, pyupgrade). | pre-commit + CI lint job |
77
+ | [**ruff**](https://docs.astral.sh/ruff/) | Linter + formatter (replaces flake8, isort, black, pyupgrade). Also enforces Google-style docstrings on public code (`D` rules). | pre-commit + CI lint job |
69
78
  | [**ty**](https://github.com/astral-sh/ty) | Static type checker by Astral (faster mypy alternative). | CI lint job + `tox -e type` |
70
- | [**pytest**](https://docs.pytest.org/) | Test runner. | Local + CI test matrix |
71
- | [**pytest-cov**](https://pytest-cov.readthedocs.io/) | Coverage reporting via `coverage.py`. | On-demand (`pytest --cov`) |
79
+ | [**pytest**](https://docs.pytest.org/) | Test runner; also runs the `>>>` examples in docstrings as doctests (`--doctest-modules`). | Local + CI test matrix |
80
+ | [**pytest-cov**](https://pytest-cov.readthedocs.io/) | Coverage reporting via `coverage.py`; enforces a minimum of 70% (`--cov-fail-under=70`). | Every `pytest` run (local + CI) |
72
81
  | [**tox**](https://tox.wiki/) + [**tox-uv**](https://github.com/tox-dev/tox-uv) | Isolated test environments per Python version (3.11, 3.12, 3.13) backed by uv for speed. | Local + CI test matrix |
73
82
  | [**pre-commit**](https://pre-commit.com/) | Git hook framework — runs ruff and conventional-commit checks before every commit. | Local |
74
83
  | [**conventional-pre-commit**](https://github.com/compilerla/conventional-pre-commit) | Pure-Python validator for [Conventional Commits](https://www.conventionalcommits.org/) commit messages. | pre-commit (commit-msg stage) |
75
84
  | [**commitlint**](https://commitlint.js.org/) | Node-based validator that re-checks every commit on a PR. | CI `commitlint` job |
85
+ | [**Zensical**](https://zensical.org/) + [**mkdocstrings**](https://mkdocstrings.github.io/python/) | Documentation site; the API Reference is generated from docstrings. | CI `docs` job, GitHub Pages on release |
76
86
  | [**hatchling**](https://hatch.pypa.io/) | PEP 517 build backend used by `uv build` to produce wheel/sdist. | Build / publish |
77
87
  | [**release-please**](https://github.com/googleapis/release-please) | Parses Conventional Commits → bumps version → updates CHANGELOG → tags releases. | CI on push to `main` |
78
88
  | [**claude-code-action**](https://github.com/anthropics/claude-code-action) | Claude reviews PRs on demand when you comment `@claude`. | CI on PR comment |
@@ -101,6 +111,10 @@ uv run ty check src
101
111
  # Build the distribution locally
102
112
  uv build
103
113
 
114
+ # Documentation: live preview on http://localhost:8000, or strict build into site/
115
+ uv run --group docs zensical serve
116
+ uv run --group docs zensical build
117
+
104
118
  # Add a new dependency (auto-updates uv.lock — commit both files)
105
119
  uv add httpx
106
120
  uv add --group dev pytest-mock
@@ -120,10 +134,80 @@ Examples:
120
134
  Enforced locally by `conventional-pre-commit` (commit-msg hook) and in CI by
121
135
  `commitlint`.
122
136
 
137
+ ## Quality gates
138
+
139
+ Nothing lands on `main` without passing CI. A GitHub ruleset
140
+ (`main-protection`, see [setup step 7](#first-time-setup-after-cloning-the-template))
141
+ requires a PR and these status checks to be green before merging:
142
+
143
+ | Check | What it enforces |
144
+ |---|---|
145
+ | `lint` | `ruff check` (including docstring rules), `ruff format --check`, `ty check src` |
146
+ | `test (3.11)`, `test (3.12)`, `test (3.13)` | Unit tests and doctests pass **and** total coverage is at least 70% |
147
+ | `commitlint` | Every commit in the PR follows Conventional Commits |
148
+ | `docs` | The documentation site builds in strict mode |
149
+
150
+ ### Test coverage
151
+
152
+ Coverage is measured on every `pytest` run: the flags live in
153
+ `[tool.pytest.ini_options].addopts` in `pyproject.toml`. If total coverage
154
+ drops below 70%, pytest exits with an error even when all tests pass, which
155
+ fails the `test` jobs and blocks the merge.
156
+
157
+ ```bash
158
+ uv run pytest # tests + coverage table with missing lines
159
+ uv run pytest --cov-report=html # HTML report, then: open htmlcov/index.html
160
+ uv run pytest --no-cov # quick run without coverage
161
+ ```
162
+
163
+ To change the threshold, edit `--cov-fail-under` in `pyproject.toml`.
164
+
165
+ ## Documentation
166
+
167
+ The site at https://wozniakos10.github.io/test_python_package_release/ is
168
+ built with [Zensical](https://zensical.org/) from two sources:
169
+
170
+ - **Hand-written pages** in `docs/` (Markdown), listed in `nav` in
171
+ `zensical.toml`. `docs/superpowers/` holds internal design notes and is
172
+ excluded from the site.
173
+ - **API Reference**, generated automatically: the `api-autonav` plugin creates
174
+ one page per module in `src/test_python_package_release/`, and
175
+ `mkdocstrings` renders each function's signature, type hints and
176
+ Google-style docstring. A new module or function shows up in the docs
177
+ without touching any docs file.
178
+
179
+ Every public module and function needs a docstring (ruff `D` rules, Google
180
+ convention). Examples written as `>>>` doctests are executed by pytest, so
181
+ they cannot drift from the code:
182
+
183
+ ```python
184
+ def divide(a: float, b: float) -> float:
185
+ """Divide one number by another.
186
+
187
+ Args:
188
+ a: Dividend.
189
+ b: Divisor.
190
+
191
+ Returns:
192
+ The quotient of ``a`` and ``b``.
193
+
194
+ Raises:
195
+ ZeroDivisionError: If ``b`` is zero.
196
+
197
+ Examples:
198
+ >>> divide(6, 3)
199
+ 2.0
200
+ """
201
+ ```
202
+
203
+ `docs.yml` builds the site in strict mode on every PR (the `docs` check) and
204
+ deploys it to GitHub Pages when a release is published (or on manual run).
205
+
123
206
  ## Release flow
124
207
 
125
208
  ```
126
- PR opened ──▶ ci.yml (lint, ty, pytest matrix, commitlint)
209
+ PR opened ──▶ ci.yml (lint, ty, pytest + doctests matrix, commitlint)
210
+ ──▶ docs.yml (strict docs build)
127
211
  │
128
212
  └─ optional: comment "@claude" ──▶ claude-review.yml
129
213
 
@@ -134,12 +218,14 @@ PR merged ──▶ main ──▶ release-please.yml
134
218
 
135
219
  Release PR merged ──▶ release-please tags + creates GitHub Release
136
220
  │
137
- └─ publish.yml ──▶ uv build
138
- ──▶ TestPyPI (OIDC)
139
- ──▶ PyPI (OIDC, gated env)
221
+ ├─ publish.yml ──▶ uv build
222
+ │ ──▶ TestPyPI (OIDC)
223
+ │ ──▶ PyPI (OIDC, gated env)
224
+ │
225
+ ├─ docker-publish.yml ──▶ Docker Hub
226
+ │ (<version>, <major.minor>, sha-*)
140
227
  │
141
- └─ docker-publish.yml ──▶ Docker Hub
142
- (<version>, <major.minor>, sha-*)
228
+ └─ docs.yml ──▶ GitHub Pages
143
229
  ```
144
230
 
145
231
  ## Docker image
@@ -197,13 +283,26 @@ Required repo configuration (Settings → Secrets and variables → Actions):
197
283
  pattern that release-please produces — by default
198
284
  `<package-name>-v*` (e.g. `test-python-package-release-v*`)
199
285
 
200
- 7. **(Optional) Branch protection ruleset** for `main`:
201
- - Require a PR before merging
202
- - Require status checks: `lint`, `test (3.11)`, `test (3.12)`,
203
- `test (3.13)`, `commitlint`
204
- - Block force pushes, restrict deletions
205
- - Add yourself to the bypass list so you can merge release-please PRs
206
-
207
- 8. **(Optional) Production gate** for PyPI publishing — on Pro/Team/Enterprise
286
+ 7. **Branch protection ruleset** for `main`: Settings → Rules → Rulesets →
287
+ New branch ruleset (this repo uses one named `main-protection`):
288
+ - **Enforcement status**: Active (a Disabled ruleset enforces nothing)
289
+ - **Target branches**: Include default branch (`main`)
290
+ - **Restrict deletions** and **Block force pushes**
291
+ - **Require a pull request before merging** (required approvals can stay
292
+ at 0 for a solo project)
293
+ - **Require status checks to pass**, then Add checks: `lint`,
294
+ `test (3.11)`, `test (3.12)`, `test (3.13)`, `commitlint`, `docs`.
295
+ A check appears in the search only after it has run at least once in
296
+ the repo. "Require branches to be up to date" is optional and stricter.
297
+ - Release PRs from release-please run the same checks (they are created
298
+ with `RELEASE_PLEASE_TOKEN`), so they merge like any other PR. Add
299
+ yourself to the bypass list only if you need an emergency override.
300
+
301
+ 8. **GitHub Pages**: Settings → Pages → Source: **GitHub Actions**. Then in
302
+ Settings → Environments → `github-pages` (created automatically) add a
303
+ **tag** deployment rule `test-python-package-release-v*` next to `main`:
304
+ the deploy job runs on the release tag, which is rejected otherwise.
305
+
306
+ 9. **(Optional) Production gate** for PyPI publishing — on Pro/Team/Enterprise
208
307
  plans only: add a Required reviewer on the `pypi` environment to require
209
308
  manual approval before production publish.
@@ -0,0 +1,7 @@
1
+ test_python_package_release/__init__.py,sha256=wcN82s0kuqMWEt8VBwXFeoT8pAxrPYDx82PVR48yR-I,650
2
+ test_python_package_release/calculator.py,sha256=_AOtalm6a5o3U9XEO1KGNtQwenFdDkl6Cjn6fYzEVrw,3405
3
+ test_python_package_release/strings.py,sha256=F01arKJ0GRScwdA8_kK3phtBSI0M6yywem2fo-uiO98,2108
4
+ test_python_package_release-0.6.0.dist-info/METADATA,sha256=jeWY7_fLcMAA-i1dkLhDYuqGStHryDOQ1021G5gNijs,14270
5
+ test_python_package_release-0.6.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
+ test_python_package_release-0.6.0.dist-info/licenses/LICENSE,sha256=FK3qjfsYq7ZWgF5WWecz0lQFe6PoBbKyNYK2hBs0aN8,1070
7
+ test_python_package_release-0.6.0.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- test_python_package_release/__init__.py,sha256=k0AMN3tPNRqhjz6_7uUgBHXeH32Pj3VaZdH6DOt1UbI,639
2
- test_python_package_release/calculator.py,sha256=XTfDYYo7j4CJwqVsrgTTP3EggwvW5WvFHloi3Y3OU_U,799
3
- test_python_package_release/strings.py,sha256=y92FYBlBjHi-NeK0NKUIudqKvjtedl9rFJJLaFFOVPc,632
4
- test_python_package_release-0.5.0.dist-info/METADATA,sha256=gMeMx9dr9eSZIqfTyFPCsFjcnzzQGeZBvqXtByWlHx8,9496
5
- test_python_package_release-0.5.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
- test_python_package_release-0.5.0.dist-info/licenses/LICENSE,sha256=FK3qjfsYq7ZWgF5WWecz0lQFe6PoBbKyNYK2hBs0aN8,1070
7
- test_python_package_release-0.5.0.dist-info/RECORD,,