action0-req 0.1.0__tar.gz

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.
@@ -0,0 +1,99 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ # cancel superseded runs of the same branch / PR
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ checks:
16
+ name: checks (python ${{ matrix.python-version }})
17
+ runs-on: ubuntu-latest
18
+ continue-on-error: ${{ matrix.experimental }}
19
+ strategy:
20
+ fail-fast: false
21
+ matrix:
22
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
23
+ experimental: [false]
24
+ include:
25
+ # 3.15 is still a pre-release: run it, but don't fail the whole
26
+ # workflow while parts of the toolchain don't support it yet
27
+ - python-version: "3.15"
28
+ experimental: true
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+
33
+ - name: Install uv
34
+ uses: astral-sh/setup-uv@v6
35
+ with:
36
+ python-version: ${{ matrix.python-version }}
37
+
38
+ - name: Install dependencies
39
+ run: uv sync --locked
40
+
41
+ - name: ruff format
42
+ run: uv run ruff format --check
43
+
44
+ - name: ruff check
45
+ run: uv run ruff check
46
+
47
+ - name: mypy
48
+ run: uv run mypy
49
+
50
+ - name: pyright
51
+ run: uv run pyright
52
+
53
+ - name: ty
54
+ run: uv run ty check
55
+
56
+ - name: pytest
57
+ run: uv run pytest
58
+
59
+ docs:
60
+ name: docs build
61
+ runs-on: ubuntu-latest
62
+ steps:
63
+ - uses: actions/checkout@v4
64
+
65
+ - name: Install uv
66
+ uses: astral-sh/setup-uv@v6
67
+
68
+ - name: Install dependencies
69
+ run: uv sync --locked --group docs
70
+
71
+ - name: Build documentation (warnings are errors)
72
+ run: uv run --group docs sphinx-build -W --keep-going -b html docs docs/_build/html
73
+
74
+ - name: Upload pages artifact
75
+ uses: actions/upload-pages-artifact@v3
76
+ with:
77
+ path: docs/_build/html
78
+
79
+ deploy-docs:
80
+ name: deploy docs
81
+ # publish only what landed on main
82
+ if: github.event_name == 'push' && github.ref == 'refs/heads/main'
83
+ needs: docs
84
+ runs-on: ubuntu-latest
85
+ permissions:
86
+ contents: read
87
+ pages: write
88
+ id-token: write
89
+ environment:
90
+ name: github-pages
91
+ url: ${{ steps.deployment.outputs.page_url }}
92
+ # the Pages site itself was enabled once via
93
+ # `gh api repos/<owner>/<repo>/pages -X POST -f build_type=workflow`;
94
+ # creating it from a workflow is impossible (GITHUB_TOKEN cannot get
95
+ # repo-administration rights)
96
+ steps:
97
+ - name: Deploy to GitHub Pages
98
+ id: deployment
99
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,62 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ build:
9
+ name: check and build
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v6
16
+
17
+ - name: Install dependencies
18
+ run: uv sync --locked
19
+
20
+ - name: Run all checks
21
+ run: |
22
+ uv run ruff format --check
23
+ uv run ruff check
24
+ uv run mypy
25
+ uv run pyright
26
+ uv run ty check
27
+ uv run pytest
28
+
29
+ - name: Check that the tag matches __version__
30
+ run: |
31
+ version=$(uv run python -c "from action0.req import __version__; print(__version__)")
32
+ if [ "v$version" != "$GITHUB_REF_NAME" ]; then
33
+ echo "tag $GITHUB_REF_NAME does not match __version__ $version" >&2
34
+ exit 1
35
+ fi
36
+
37
+ - name: Build sdist and wheel
38
+ run: uv build
39
+
40
+ - uses: actions/upload-artifact@v4
41
+ with:
42
+ name: dist
43
+ path: dist/
44
+
45
+ publish:
46
+ name: publish to PyPI
47
+ needs: build
48
+ runs-on: ubuntu-latest
49
+ environment:
50
+ name: pypi
51
+ url: https://pypi.org/p/action0-req
52
+ permissions:
53
+ # OIDC token for PyPI trusted publishing
54
+ id-token: write
55
+ steps:
56
+ - uses: actions/download-artifact@v4
57
+ with:
58
+ name: dist
59
+ path: dist/
60
+
61
+ - name: Publish to PyPI
62
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,16 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Editor files
13
+ .idea
14
+
15
+ # Sphinx build output
16
+ docs/_build/
@@ -0,0 +1 @@
1
+ 3.14
@@ -0,0 +1,56 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project
6
+
7
+ `action0-req` is a Python library for representing, creating and manipulating HTTP requests and responses. It ships the `action0.req` package (`action0` is a PEP 420 namespace package) from a `src/` layout, is built with hatchling, and uses `uv` for environment/dependency management. Its only runtime dependency is `action0-url` (the URL representation), pulled from PyPI.
8
+
9
+ ## Rules
10
+
11
+ - **Never commit without asking.** Also never push, tag, or publish on your own.
12
+ - **Branches + PRs.** All changes go through feature branches and GitHub pull requests that Simon reviews and merges — never commit to `main` directly. (Only the initial implementation was built directly on `main`; that phase is over.)
13
+ - **Discuss first.** Always present the plan and the intended edits and get agreement before changing files.
14
+ - Every code change comes with: tests, docstrings, inline comments where the code isn't self-explanatory, and updated usage examples in `README.md` and the Sphinx docs (`docs/usage.md`).
15
+ - Before considering work done, run ruff, mypy, and pytest (commands below) and fix what they report.
16
+ - Supported Python versions: 3.11 up to the latest release. Don't use syntax or stdlib features introduced after 3.11, and don't rely on behavior removed in newer versions.
17
+
18
+ ## Commands
19
+
20
+ `uv run` syncs the environment automatically (the dev dependency group is installed by default), so no separate install step is needed.
21
+
22
+ ```sh
23
+ uv run pytest # all tests
24
+ uv run pytest tests/action0/req/test_init.py # one file
25
+ uv run pytest tests/action0/req/test_init.py::PackageTestCase::test_version # one test
26
+
27
+ uv run ruff check # lint (add --fix to autofix)
28
+ uv run ruff format # format
29
+ uv run mypy # type-check (strict; files are configured in pyproject.toml)
30
+ uv run pyright # type-check
31
+ uv run ty check # type-check
32
+
33
+ uv run --group docs sphinx-build -W --keep-going -b html docs docs/_build/html # build docs
34
+
35
+ uv build # build sdist + wheel into dist/
36
+ ```
37
+
38
+ `pytest` also runs the `>>>` examples in the docstrings as doctests (`--doctest-modules` over `src/`), so docstring examples must produce their shown output exactly.
39
+
40
+ ## Architecture
41
+
42
+ The package is being built up module by module under `src/action0/req/`. Planned/current layout:
43
+
44
+ - `headers.py` — `Headers`: ordered, case-insensitive, multi-value aware mapping of header fields, internally a `list[tuple[str, str]]` of lines preserving the representation (order and casing) exactly. The `MutableMapping` view is single-value (last line per field, like `Params`); `get_all()`/`get_values()` (RFC 9110 comma-splitting)/`add()`/`set()`/`remove()`/`update()`/`as_lines()`/`as_dict()`/`as_str()` handle multiple lines. No underscore→dash normalization (header smuggling footgun). `__eq__` ignores field order and name casing but respects per-field line order; `repr()`/`str()` redact the values of `Headers.secret_names` with `***` — only the wire rendering `as_str()` keeps them. Also `Header`: `StrEnum` of the IANA HTTP field name registry (permanent + deprecated + provisional registrations, generated from the registry CSV on 2026-08-07) plus a block of unregistered de-facto `X-…` names.
45
+ - `status.py` — `Status`: custom `IntEnum` of the IANA status code registry with `phrase` and `is_informational`/`is_success`/`is_redirection`/`is_client_error`/`is_server_error` properties. Deliberately not `http.HTTPStatus`: the stdlib's code list and category properties vary across 3.11–3.15. Two pre-RFC-9110 aliases (`PAYLOAD_TOO_LARGE`, `UNPROCESSABLE_ENTITY`).
46
+ - `request.py` — `Method`: `StrEnum` of the RFC 9110 verbs + `PATCH` + `QUERY`. `Request`: method (uppercased str), `url` (`action0.url.Url` — copied on ingestion, `query=` kwarg replaces the URL's query like the `Url` constructor), `headers` (`Headers`), `body` (`bytes | str | BodyProducer | None`, stored as set), `http_version` and a `meta` dict (application metadata: never on the wire, excluded from `__eq__`, shallow-copied by `copy()`; the constructor copies the given mapping) as plain attributes. Typed body accessors `body_bytes()`/`body_str()`/`body_producer()` convert between the three forms using the Content-Type charset (default utf-8). `copy(**overrides)` (own `Url`/`Headers`; a `BodyProducer` body is shared), part-wise `__eq__` (body compared as set), `repr()` redacts via `Url.__repr__` and omits headers/body, `as_str(include_body=False, separator="\r\n")` renders the wire format with origin-form target and derived `Host` (secrets included; a `BodyProducer` is never consumed — placeholder).
47
+ - `body.py` — `BodyProducer`: runtime-checkable `Protocol` for streaming bodies: `content_length()` (`None` = unknown), sync `chunks()`, async `achunks()`, `as_bytes()`. Implementations: `BytesBody` (in-memory, single chunk), `FileBody` (path or open binary file object + `chunk_size`; paths open freshly per iteration → re-iterable, seekable file objects are rewound per iteration and never closed, non-seekable ones are single-use with unknown length; `achunks()` does all file ops via `asyncio.to_thread`), `IterableBody` (wraps `Iterable[bytes]`, unknown length, generator sources single-use), `AsyncIterableBody` (wraps `AsyncIterable[bytes]`, async-only: sync `chunks()`/`as_bytes()` raise `RuntimeError`). Also the `BodyTypes` alias and the private conversion helpers (`_charset`, `_body_bytes`/`_body_str`/`_body_producer`, `_rendered_body`) shared by `Request` and `Response` — the classes keep their own thin, documented accessor methods.
48
+ - `response.py` — `Response`: `status` (any int; `Status` members welcome), `headers`, `body`, `reason` (server-sent phrase; the `phrase` property falls back to the `Status` registry, `""` for unknown codes), `http_version`, an optional `request` back-reference (metadata: shared, not copied, excluded from `__eq__`) and a `meta` dict like `Request`'s. Category properties (`is_success`, …) computed from the numeric range so unregistered codes work. Same body accessors as `Request`; `copy(**overrides)`, `as_str(include_body, separator)` with status line, redacting-by-omission `repr()` (`Response(404 Not Found)`).
49
+
50
+ Conventions:
51
+
52
+ - The version is single-sourced as `__version__` in `src/action0/req/__init__.py`; hatch extracts it with the regex in `[tool.hatch.version]`. Bump it only there.
53
+ - Releases: pushing a `vX.Y.Z` tag triggers `.github/workflows/release.yml`, which re-runs all checks, verifies the tag matches `__version__`, builds, and publishes to PyPI via trusted publishing (environment `pypi`). Never bump the version, tag, or publish on your own — releasing is the user's call.
54
+ - Tests mirror the `src/` layout under `tests/action0/req/` and are `unittest.TestCase` classes, executed via pytest.
55
+ - Ruff enforces one import per line (isort `force-single-line`), line length 99, `action0` as first-party.
56
+ - Docs live in `docs/` (Sphinx + Furo, MyST Markdown pages, autodoc for the API reference). Docstrings are Sphinx-reST (`:param:`, `:py:meth:` roles). CI builds them with `-W` on every run and deploys to GitHub Pages on pushes to `main`. Guide examples in `docs/usage.md` show exact outputs in `#` comments — keep them truthful.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LaughInJar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: action0-req
3
+ Version: 0.1.0
4
+ Summary: Library for representing, creating and manipulating HTTP requests and responses
5
+ Project-URL: Homepage, https://github.com/LaughInJar/action0-req
6
+ Project-URL: Documentation, https://laughinjar.github.io/action0-req/
7
+ Project-URL: Source, https://github.com/LaughInJar/action0-req
8
+ Project-URL: Issues, https://github.com/LaughInJar/action0-req/issues
9
+ Author: Simon Lachinger
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: headers,http,manipulation,request,response,status
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Topic :: Internet :: WWW/HTTP
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Requires-Dist: action0-url>=0.1.0
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Action0-Req
30
+
31
+ [![CI](https://github.com/LaughInJar/action0-req/actions/workflows/ci.yml/badge.svg)](https://github.com/LaughInJar/action0-req/actions/workflows/ci.yml)
32
+ [![PyPI](https://img.shields.io/pypi/v/action0-req)](https://pypi.org/project/action0-req/)
33
+
34
+ Typed Python representations of HTTP requests and responses with
35
+ convenient creation, duplication and manipulation. The companion of
36
+ [action0-url](https://github.com/LaughInJar/action0-url), which provides
37
+ the URL representation.
38
+
39
+ Requires Python 3.11 or newer.
40
+
41
+ Full documentation including the API reference:
42
+ <https://laughinjar.github.io/action0-req/>
43
+
44
+ **Status:** the core API is complete — the header name, status code and
45
+ method constants, the `Headers` mapping, `Request` and `Response`, and
46
+ sync/async body streaming via `BodyProducer` (`BytesBody`, `FileBody`,
47
+ `IterableBody`, `AsyncIterableBody`).
48
+
49
+ ## Usage
50
+
51
+ `Header`, `Status` and `Method` are `StrEnum`/`IntEnum` constants for the
52
+ IANA-registered header field names, status codes and request methods —
53
+ every member *is* its string or integer value:
54
+
55
+ ```python
56
+ from action0.req import Header, Method, Status
57
+
58
+ print(Header.CONTENT_TYPE) # Content-Type
59
+ print(Method.POST) # POST
60
+ print(Status.NOT_FOUND) # 404
61
+ print(Status.NOT_FOUND.phrase) # Not Found
62
+ print(Status.NOT_FOUND.is_client_error) # True
63
+ ```
64
+
65
+ `Headers` is an ordered, case-insensitive, multi-value aware mapping of
66
+ header fields that preserves the representation (order and casing)
67
+ exactly:
68
+
69
+ ```python
70
+ from action0.req import Headers
71
+
72
+ headers = Headers({"Content-Type": "text/html"})
73
+ headers.add("Set-Cookie", "a=1")
74
+ headers.add("set-cookie", "b=2")
75
+ print(headers["CONTENT-TYPE"]) # text/html
76
+ print(headers.get_all("Set-Cookie")) # ['a=1', 'b=2']
77
+ print(headers.as_str(separator="\n")) # "\r\n" by default
78
+ # Content-Type: text/html
79
+ # Set-Cookie: a=1
80
+ # set-cookie: b=2
81
+
82
+ # repr()/str() redact secrets, only as_str() renders them
83
+ print(Headers({"Authorization": "Bearer tok"})) # Headers(Authorization: ***)
84
+ ```
85
+
86
+ `Request` combines a method, a `Url` (from action0-url), `Headers`, a
87
+ `meta` dict for application metadata (never on the wire) and a body (`bytes`, `str` or a streaming `BodyProducer` — retrievable in any
88
+ of the three forms):
89
+
90
+ ```python
91
+ from action0.req import Request
92
+
93
+ req = Request("https://api.example.com/items", query={"page": 2})
94
+ req.headers["Accept"] = "application/json"
95
+ print(req.as_str(separator="\n")) # "\r\n" by default
96
+ # GET /items?page=2 HTTP/1.1
97
+ # Host: api.example.com
98
+ # Accept: application/json
99
+
100
+ post = req.copy(method="POST", body='{"a": 1}')
101
+ print(post.body_bytes()) # b'{"a": 1}'
102
+ print(post) # Request(POST https://api.example.com/items?page=2)
103
+ ```
104
+
105
+ `Response` mirrors it for the server side — status (with reason phrase
106
+ fallback and category properties), headers, body:
107
+
108
+ ```python
109
+ from action0.req import Response, Status
110
+
111
+ resp = Response(Status.NOT_FOUND, headers={"Content-Type": "text/plain"}, body="not here")
112
+ print(resp.phrase, resp.is_client_error) # Not Found True
113
+ print(resp.as_str(separator="\n")) # "\r\n" by default
114
+ # HTTP/1.1 404 Not Found
115
+ # Content-Type: text/plain
116
+ ```
117
+
118
+ ## Installation
119
+
120
+ Not published to PyPI yet; install straight from GitHub:
121
+
122
+ ```shell
123
+ uv add "action0-req @ git+https://github.com/LaughInJar/action0-req"
124
+ ```
125
+
126
+ ## Development
127
+
128
+ The project is managed with [uv](https://docs.astral.sh/uv/); `uv run`
129
+ creates and syncs the virtual environment automatically:
130
+
131
+ ```shell
132
+ uv run pytest # run the tests (incl. the docstring examples as doctests)
133
+ uv run ruff check # lint
134
+ uv run ruff format # format
135
+ uv run mypy # type-check (also: uv run pyright, uv run ty check)
136
+
137
+ # build the docs (Sphinx; deployed to GitHub Pages on push to main)
138
+ uv run --group docs sphinx-build -W docs docs/_build/html
139
+ ```
140
+
141
+ ### Releasing
142
+
143
+ The version lives only in `src/action0/req/__init__.py` (`__version__`).
144
+ To release: bump it, merge to `main`, then tag the release commit and push
145
+ the tag — the release workflow re-runs all checks, verifies the tag
146
+ matches `__version__`, builds sdist + wheel and publishes to PyPI via
147
+ trusted publishing:
148
+
149
+ ```shell
150
+ git tag v0.1.0
151
+ git push origin v0.1.0
152
+ ```
153
+
154
+ ## AI-assisted development
155
+
156
+ In the spirit of transparency: most of this project's code, tests and
157
+ documentation are written by [Claude Code](https://claude.com/claude-code),
158
+ Anthropic's coding agent — under human direction and review. The designs
159
+ are specified, discussed and iterated by a human, and every change is
160
+ reviewed before it lands in `main` or in a release. AI-authored commits
161
+ carry a `Co-Authored-By: Claude ...` trailer.
162
+
163
+ ## About action0
164
+
165
+ This is just the namespace I like to use for my personal projects.
166
+ I quite like namespaces.
@@ -0,0 +1,138 @@
1
+ # Action0-Req
2
+
3
+ [![CI](https://github.com/LaughInJar/action0-req/actions/workflows/ci.yml/badge.svg)](https://github.com/LaughInJar/action0-req/actions/workflows/ci.yml)
4
+ [![PyPI](https://img.shields.io/pypi/v/action0-req)](https://pypi.org/project/action0-req/)
5
+
6
+ Typed Python representations of HTTP requests and responses with
7
+ convenient creation, duplication and manipulation. The companion of
8
+ [action0-url](https://github.com/LaughInJar/action0-url), which provides
9
+ the URL representation.
10
+
11
+ Requires Python 3.11 or newer.
12
+
13
+ Full documentation including the API reference:
14
+ <https://laughinjar.github.io/action0-req/>
15
+
16
+ **Status:** the core API is complete — the header name, status code and
17
+ method constants, the `Headers` mapping, `Request` and `Response`, and
18
+ sync/async body streaming via `BodyProducer` (`BytesBody`, `FileBody`,
19
+ `IterableBody`, `AsyncIterableBody`).
20
+
21
+ ## Usage
22
+
23
+ `Header`, `Status` and `Method` are `StrEnum`/`IntEnum` constants for the
24
+ IANA-registered header field names, status codes and request methods —
25
+ every member *is* its string or integer value:
26
+
27
+ ```python
28
+ from action0.req import Header, Method, Status
29
+
30
+ print(Header.CONTENT_TYPE) # Content-Type
31
+ print(Method.POST) # POST
32
+ print(Status.NOT_FOUND) # 404
33
+ print(Status.NOT_FOUND.phrase) # Not Found
34
+ print(Status.NOT_FOUND.is_client_error) # True
35
+ ```
36
+
37
+ `Headers` is an ordered, case-insensitive, multi-value aware mapping of
38
+ header fields that preserves the representation (order and casing)
39
+ exactly:
40
+
41
+ ```python
42
+ from action0.req import Headers
43
+
44
+ headers = Headers({"Content-Type": "text/html"})
45
+ headers.add("Set-Cookie", "a=1")
46
+ headers.add("set-cookie", "b=2")
47
+ print(headers["CONTENT-TYPE"]) # text/html
48
+ print(headers.get_all("Set-Cookie")) # ['a=1', 'b=2']
49
+ print(headers.as_str(separator="\n")) # "\r\n" by default
50
+ # Content-Type: text/html
51
+ # Set-Cookie: a=1
52
+ # set-cookie: b=2
53
+
54
+ # repr()/str() redact secrets, only as_str() renders them
55
+ print(Headers({"Authorization": "Bearer tok"})) # Headers(Authorization: ***)
56
+ ```
57
+
58
+ `Request` combines a method, a `Url` (from action0-url), `Headers`, a
59
+ `meta` dict for application metadata (never on the wire) and a body (`bytes`, `str` or a streaming `BodyProducer` — retrievable in any
60
+ of the three forms):
61
+
62
+ ```python
63
+ from action0.req import Request
64
+
65
+ req = Request("https://api.example.com/items", query={"page": 2})
66
+ req.headers["Accept"] = "application/json"
67
+ print(req.as_str(separator="\n")) # "\r\n" by default
68
+ # GET /items?page=2 HTTP/1.1
69
+ # Host: api.example.com
70
+ # Accept: application/json
71
+
72
+ post = req.copy(method="POST", body='{"a": 1}')
73
+ print(post.body_bytes()) # b'{"a": 1}'
74
+ print(post) # Request(POST https://api.example.com/items?page=2)
75
+ ```
76
+
77
+ `Response` mirrors it for the server side — status (with reason phrase
78
+ fallback and category properties), headers, body:
79
+
80
+ ```python
81
+ from action0.req import Response, Status
82
+
83
+ resp = Response(Status.NOT_FOUND, headers={"Content-Type": "text/plain"}, body="not here")
84
+ print(resp.phrase, resp.is_client_error) # Not Found True
85
+ print(resp.as_str(separator="\n")) # "\r\n" by default
86
+ # HTTP/1.1 404 Not Found
87
+ # Content-Type: text/plain
88
+ ```
89
+
90
+ ## Installation
91
+
92
+ Not published to PyPI yet; install straight from GitHub:
93
+
94
+ ```shell
95
+ uv add "action0-req @ git+https://github.com/LaughInJar/action0-req"
96
+ ```
97
+
98
+ ## Development
99
+
100
+ The project is managed with [uv](https://docs.astral.sh/uv/); `uv run`
101
+ creates and syncs the virtual environment automatically:
102
+
103
+ ```shell
104
+ uv run pytest # run the tests (incl. the docstring examples as doctests)
105
+ uv run ruff check # lint
106
+ uv run ruff format # format
107
+ uv run mypy # type-check (also: uv run pyright, uv run ty check)
108
+
109
+ # build the docs (Sphinx; deployed to GitHub Pages on push to main)
110
+ uv run --group docs sphinx-build -W docs docs/_build/html
111
+ ```
112
+
113
+ ### Releasing
114
+
115
+ The version lives only in `src/action0/req/__init__.py` (`__version__`).
116
+ To release: bump it, merge to `main`, then tag the release commit and push
117
+ the tag — the release workflow re-runs all checks, verifies the tag
118
+ matches `__version__`, builds sdist + wheel and publishes to PyPI via
119
+ trusted publishing:
120
+
121
+ ```shell
122
+ git tag v0.1.0
123
+ git push origin v0.1.0
124
+ ```
125
+
126
+ ## AI-assisted development
127
+
128
+ In the spirit of transparency: most of this project's code, tests and
129
+ documentation are written by [Claude Code](https://claude.com/claude-code),
130
+ Anthropic's coding agent — under human direction and review. The designs
131
+ are specified, discussed and iterated by a human, and every change is
132
+ reviewed before it lands in `main` or in a release. AI-authored commits
133
+ carry a `Co-Authored-By: Claude ...` trailer.
134
+
135
+ ## About action0
136
+
137
+ This is just the namespace I like to use for my personal projects.
138
+ I quite like namespaces.
@@ -0,0 +1,51 @@
1
+ # API reference
2
+
3
+ The public constants and classes are importable from the package root:
4
+
5
+ ```python
6
+ from action0.req import Header, Headers, Method, Request, Response, Status
7
+ from action0.req import BodyProducer, BytesBody
8
+ ```
9
+
10
+ ## Headers and Header
11
+
12
+ ```{eval-rst}
13
+ .. automodule:: action0.req.headers
14
+ :members:
15
+ :undoc-members:
16
+ :special-members: __eq__, __getitem__, __setitem__, __delitem__, __iter__, __len__, __contains__, __repr__
17
+ ```
18
+
19
+ ## Request and Method
20
+
21
+ ```{eval-rst}
22
+ .. automodule:: action0.req.request
23
+ :members:
24
+ :undoc-members:
25
+ :special-members: __eq__, __repr__
26
+ ```
27
+
28
+ ## Response
29
+
30
+ ```{eval-rst}
31
+ .. automodule:: action0.req.response
32
+ :members:
33
+ :undoc-members:
34
+ :special-members: __eq__, __repr__
35
+ ```
36
+
37
+ ## Body producers
38
+
39
+ ```{eval-rst}
40
+ .. automodule:: action0.req.body
41
+ :members:
42
+ :undoc-members:
43
+ ```
44
+
45
+ ## Status
46
+
47
+ ```{eval-rst}
48
+ .. automodule:: action0.req.status
49
+ :members:
50
+ :undoc-members:
51
+ ```
@@ -0,0 +1,46 @@
1
+ """Sphinx configuration for the action0-req documentation."""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ # make the package importable even without an installed wheel
7
+ sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
8
+
9
+ from action0.req import __version__ # noqa: E402
10
+
11
+ project = "action0-req"
12
+ author = "Simon Lachinger"
13
+ project_copyright = "2026, Simon Lachinger"
14
+ version = __version__
15
+ release = __version__
16
+
17
+ extensions = [
18
+ "myst_parser",
19
+ "sphinx.ext.autodoc",
20
+ "sphinx.ext.doctest",
21
+ "sphinx.ext.intersphinx",
22
+ "sphinx.ext.viewcode",
23
+ "sphinx_autodoc_typehints",
24
+ "sphinx_copybutton",
25
+ ]
26
+
27
+ # link references like :py:class:`http.HTTPStatus` to the Python docs and
28
+ # references to the action0.url classes to the action0-url docs
29
+ intersphinx_mapping = {
30
+ "python": ("https://docs.python.org/3", None),
31
+ "action0-url": ("https://laughinjar.github.io/action0-url/", None),
32
+ }
33
+
34
+ # order the API reference like the source files and merge the rich __init__
35
+ # docstrings into their class documentation
36
+ autodoc_member_order = "bysource"
37
+ autoclass_content = "both"
38
+
39
+ # sphinx-autodoc-typehints: document every parameter type and default value
40
+ always_document_param_types = True
41
+ typehints_defaults = "comma"
42
+
43
+ myst_enable_extensions = ["colon_fence"]
44
+
45
+ html_theme = "furo"
46
+ html_title = f"action0-req {__version__}"