Skip to content

chore: project hygiene tidy — publish guard, uv_build band, HTTPStatus, Response.json() charset#18

Merged
lesnik512 merged 7 commits into
mainfrom
chore/project-hygiene-tidy
Jun 2, 2026
Merged

chore: project hygiene tidy — publish guard, uv_build band, HTTPStatus, Response.json() charset#18
lesnik512 merged 7 commits into
mainfrom
chore/project-hygiene-tidy

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Closes four entries in planning/deferred-work.md. Spec: planning/specs/2026-06-02-project-hygiene-tidy-design.md. Plan: planning/plans/2026-06-02-project-hygiene-tidy-plan.md.

  • just publish env-var guard — refuses to run when GITHUB_REF_NAME or PYPI_TOKEN is unset, so local invocations can no longer corrupt pyproject.toml via uv version "".
  • uv_build band widening>=0.11,<0.12>=0.11,<1.0. Stops the every-minor bump treadmill; a hypothetical 0.x break surfaces as a loud build error.
  • http.HTTPStatus substitution — 11 status-code integer literals (200, 418, 503, 504) replaced with HTTPStatus.* constants across test_transports_httpx2.py, test_response.py, test_middleware.py, plus the 400/500 bounds in the 4xx/5xx dispatch block of src/httpware/transports/httpx2.py. Removes 12 of the 25 # noqa: PLR2004 instances in the repo. The synthetic < 600 upper bound keeps its noqa with an inline justification.
  • Response.json() charset fix — routes through self.text so declared charsets (e.g. iso-8859-1) are honored before JSON parsing. Strict improvement; ASCII / UTF-8 bodies unchanged. Docstring now explicitly documents the json.JSONDecodeError raise contract. Wrapping the exception in a domain type is left to a future response-API revision.

Six atomic commits, no public API break, no CI invariant change.

Test plan

  • just lint-ci exits 0
  • just test — 296 passing (one new: test_response_json_uses_declared_charset)
  • env -i PATH="$PATH" HOME="$HOME" just publish exits non-zero with GITHUB_REF_NAME is required; refusing to run outside CI and leaves pyproject.toml untouched
  • grep -rn 'PLR2004' src/ tests/ shows no remaining noqas on status-code literals (200/418/503/504/400/500); only non-status instances (counts, elapsed, intentionally-invalid status==99) and the justified < 600 synthetic-upper-bound noqa remain
  • grep -E 'just publish\|uv_build>=0\.11,<0\.12\|Response\.json' planning/deferred-work.md returns empty

🤖 Generated with Claude Code

lesnik512 and others added 6 commits June 2, 2026 23:46
Refuse to run when GITHUB_REF_NAME or PYPI_TOKEN is unset, so local
invocations cannot corrupt pyproject.toml via uv version "".

Closes deferred-work entry: "just publish lacks env-var validation".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Accept all 0.x releases; stops the every-minor bump treadmill. An
incompatible 0.x bump (hypothetical) surfaces as a loud build error
in CI, not a silent regression.

Closes deferred-work entry: "uv_build>=0.11,<0.12 narrow window".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces 11 instances of `assert status == <int>  # noqa: PLR2004`
with `assert status == HTTPStatus.<NAME>` across three test files.
Each substitution removes a noqa; HTTPStatus members are IntEnum so
behavior is unchanged.

Non-status-code PLR2004 noqas (counts, elapsed, intentionally-invalid
status==99) are out of scope.

Partial: deferred-work "PLR2004 per-file-ignores" entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces 400 → HTTPStatus.BAD_REQUEST and 500 →
HTTPStatus.INTERNAL_SERVER_ERROR in the 4xx/5xx exception dispatch
block. The < 600 synthetic upper bound has no stdlib equivalent, so
its PLR2004 noqa stays — now with an inline justification.

Closes deferred-work entry: "PLR2004 per-file-ignores" (for status
codes; non-status instances remain open).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Routes the body through self.text instead of json.loads(self.content),
so a declared charset (e.g. iso-8859-1) is respected before JSON
parsing. ASCII / UTF-8 bodies are unchanged. Docstring now explicitly
documents the json.JSONDecodeError raise contract.

Wrapping JSONDecodeError in a domain exception is left to a future
response-API revision.

Closes deferred-work entries: "Response.json() raises raw and ignores
charset" (retro) and "Response.json() honor declared charset" (1-2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removes four entries closed by this PR (just publish guard, uv_build
band, Response.json() charset+raise — last one was duplicated across
the retro section and the original Story 1-2 review).

Rewords the PLR2004 entry to document what was actually done (status
codes migrated to http.HTTPStatus) and what remains open (~11 non-
status noqas on counts and primitive values).

Also fixes pre-existing missing trailing newline.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 self-assigned this Jun 2, 2026
- PydanticDecoder.decode TypeError fallback: branch is deliberately
  exercised via mock in tests; contract is pinned, no action pending.
  Steady state, not deferred work.
- PLR2004 noqas on non-status-code literals: decision made in spec
  discussion (bare noqas or per-line justifications acceptable;
  per-file-ignores rejected per user's lint-suppression hierarchy).
  Documenting current state, not deferred work.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit 261d9f3 into main Jun 2, 2026
5 checks passed
@lesnik512 lesnik512 deleted the chore/project-hygiene-tidy branch June 2, 2026 21:46
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