Modernize: Python 3 (3.10–3.14), codesorter + ruff, pyproject, tag-driven releases#5
Merged
Merged
Conversation
9d5b8ba to
33b2ffb
Compare
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.
fb97111 to
ca7ec5b
Compare
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.
ca7ec5b to
23f82df
Compare
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.
19d8f18 to
5d295ab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;argparseoveroptparse;ssl.SSLContext().wrap_socket()(the oldssl.wrap_socket()is gone in 3.12+); bytes-aware base64 +headers.get();isinstance/errnoconnection-error filtering;super(), f-strings,pathlibPackaging & tooling
pyproject.toml(hatchling) replacessetup.py+ruff.toml+MANIFEST.in; ruff config folded into[tool.ruff].pre-commit-config.yaml: codesorter v0.2.7 + ruff v0.15.17 (SHA-pinned); obsolete pep8/pylintlint.shremovedext_http_serverconsole script orpython -m ext_http_server(no shebang/executable bit needed)Tag-driven releases
[project] dynamic = ["version"],[tool.hatch.version] source = "vcs") — no version literal in the tree; the module reads its version throughimportlib.metadata.github/workflows/publish.ymlbuilds with uv and publishes to PyPI via trusted publishing on every published GitHub releasegh release create v1.0.0 --generate-notes. No bump commit, no PR, no token. Verified a clean checkout atv1.0.0builds exactlyext_http_server-1.0.0.Verification
TLS auth/range smoke test (401 / 200 / 206) via the installed entry point on Python 3.10 and 3.14;
pre-commit run -aclean and idempotent; wheel builds/installs and--versionreports 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:
ext_http_serverproject → Publishing → add a GitHub Actions trusted publisher: ownerbboe, repoextended_http_server, workflowpublish.yml, environmentpypi.pypi(Settings → Environments).