Skip to content

Modernize: Python 3 (3.10–3.14), codesorter + ruff, pyproject, tag-driven releases#5

Merged
bboe merged 5 commits into
mainfrom
modernize-and-add-codesorter
Jun 15, 2026
Merged

Modernize: Python 3 (3.10–3.14), codesorter + ruff, pyproject, tag-driven releases#5
bboe merged 5 commits into
mainfrom
modernize-and-add-codesorter

Conversation

@bboe

@bboe bboe commented Jun 15, 2026

Copy link
Copy Markdown
Owner

The module was Python 2 only and would not import on Python 3. This modernizes it end to end.

Python 3 port

  • http.server/socketserver; argparse over optparse; ssl.SSLContext().wrap_socket() (the old ssl.wrap_socket() is gone in 3.12+); bytes-aware base64 + headers.get(); isinstance/errno connection-error filtering; super(), f-strings, pathlib
  • Supports Python 3.10 through 3.14

Packaging & tooling

  • One pyproject.toml (hatchling) replaces setup.py + ruff.toml + MANIFEST.in; ruff config folded into [tool.ruff]
  • New .pre-commit-config.yaml: codesorter v0.2.7 + ruff v0.15.17 (SHA-pinned); obsolete pep8/pylint lint.sh removed
  • Runs via the ext_http_server console script or python -m ext_http_server (no shebang/executable bit needed)

Tag-driven releases

  • Version comes from the git tag via hatch-vcs ([project] dynamic = ["version"], [tool.hatch.version] source = "vcs") — no version literal in the tree; the module reads its version through importlib.metadata
  • .github/workflows/publish.yml builds with uv and publishes to PyPI via trusted publishing on every published GitHub release
  • Releasing = gh release create v1.0.0 --generate-notes. No bump commit, no PR, no token. Verified a clean checkout at v1.0.0 builds exactly ext_http_server-1.0.0.

First release supersedes the 2012 0.2 already on PyPI, so the first tag should be v1.0.0 (PyPI can't overwrite 0.2).

Verification

TLS auth/range smoke test (401 / 200 / 206) via the installed entry point on Python 3.10 and 3.14; pre-commit run -a clean and idempotent; wheel builds/installs and --version reports the metadata version. No repo tests exist, so correctness rests on the smoke test.

One-time setup required (only you can do this)

Trusted publishing must be configured on PyPI before the workflow can publish:

  1. PyPI → the ext_http_server project → Publishing → add a GitHub Actions trusted publisher: owner bboe, repo extended_http_server, workflow publish.yml, environment pypi.
  2. In the repo, create an Environment named pypi (Settings → Environments).

@bboe bboe force-pushed the modernize-and-add-codesorter branch 2 times, most recently from 9d5b8ba to 33b2ffb Compare June 15, 2026 03:10
@bboe bboe changed the title Port to Python 3 and adopt the codesorter + ruff pre-commit stack Port to Python 3 (3.10–3.14), adopt codesorter + ruff, release as 1.0 Jun 15, 2026
@bboe bboe changed the title Port to Python 3 (3.10–3.14), adopt codesorter + ruff, release as 1.0 Modernize: Python 3 (3.10–3.14), codesorter + ruff, pyproject, tag-driven releases Jun 15, 2026
bboe added 3 commits June 14, 2026 21:20
The module was Python 2 only (SocketServer/BaseHTTPServer/SimpleHTTPServer
imports, str-based base64, the removed ssl.wrap_socket) and would not import on
Python 3. Port it to http.server/socketserver, argparse, ssl.SSLContext,
pathlib, and f-strings; adopt the codesorter + ruff pre-commit stack; and
declare support for Python 3.10 through 3.14.
Replace setup.py, ruff.toml, and MANIFEST.in with one pyproject.toml on the
hatchling backend. Derive the version from the git tag via hatch-vcs (read at
runtime through importlib.metadata) and add a trusted-publishing PyPI workflow
that runs on a published GitHub release, with SHA-pinned actions. Document
installation with uv.
Add complete type annotations and turn on pyright strict (dev dependency group
plus a pre-commit hook). Switch ruff to select = ["ALL"] with preview and
resolve every finding -- http.HTTPStatus for status codes, a try-free
handle_range, documented returns -- ignoring only four rules, each justified
inline.
@bboe bboe force-pushed the modernize-and-add-codesorter branch from fb97111 to ca7ec5b Compare June 15, 2026 04:20
Add a pytest suite (pytest + trustme dependency group): unit tests for
handle_range parsing, RateLimitWriter throttling/proxying, and add_user, plus a
real TLS integration test exercising auth + Range together. Add a CI workflow
(pre-commit lint/type plus a pytest matrix over Python 3.10-3.14, SHA-pinned).
Remove stale section-banner comments, flesh out .gitignore, and give the README
a title, description, and a modern ECDSA P-256 certificate command.
@bboe bboe force-pushed the modernize-and-add-codesorter branch from ca7ec5b to 23f82df Compare June 15, 2026 04:24
Add docstrfmt, auto-walrus, toml-sort, and the pre-commit/pre-commit-hooks
battery (large-file, shebang, TOML/YAML, end-of-file, line-ending, pytest test
naming, no-commit-to-branch, and trailing-whitespace checks), and apply the
resulting docstring formatting, walrus rewrite, and TOML normalization.

Omit sort-simple-yaml, which only handles single-job workflows and corrupts this
repo's multi-job CI workflow.
@bboe bboe force-pushed the modernize-and-add-codesorter branch from 19d8f18 to 5d295ab Compare June 15, 2026 04:38
@bboe bboe merged commit 75ca10b into main Jun 15, 2026
6 checks passed
@bboe bboe deleted the modernize-and-add-codesorter branch June 15, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant