You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f9d8ed8
Browse filesBrowse the repository at this point in the historyBrowse files
feat!: pass a catalog value newer than the client through (#25)
Every catalog field of a returned model is typed `Literal[...] | str`. A
value the API adds later now arrives as it is, where the whole call raised
a `ValidationError` before. Method arguments keep their closed types.
A release condition the client cannot read, such as one of a type newer
than the client, arrives as the new `UnknownCondition`. It keeps its
`type`, and its other fields are in `model_extra`. The `conditions`
argument of `apps.channels.releases.create` takes only the five known
models.
One contract test answers every call with catalog values and condition
types the client does not know.
BREAKING CHANGE: a catalog field of a returned model is typed `Literal[...] | str`, and `Release.conditions` is a list of `ReleaseCondition | UnknownCondition`. Code checked with mypy or pyright needs a branch for an unknown value and for `UnknownCondition`, and must narrow a response value before it passes it to a method argument. See BREAKING.md.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: BREAKING.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,56 @@ This is a comprehensive list of the breaking changes introduced in the minor ver
4
4
5
5
## Versions
6
6
7
+
-[Version 0.9.x](#version-09x)
7
8
-[Version 0.8.x](#version-08x)
8
9
10
+
## Version 0.9.x
11
+
12
+
### Open Catalogs in Responses
13
+
14
+
Every catalog field of a returned model is typed `Literal[...] | str`, such as `App.framework` as `Framework | str`. A value newer than your client now arrives as it is. Before, the whole call raised a pydantic `ValidationError`. Method arguments keep their closed types.
15
+
16
+
Nothing changes at runtime for the values your client knows. Only code checked with mypy or pyright must change, in two cases.
17
+
18
+
Code that handles every value needs a branch for a value it does not know:
19
+
20
+
```diff
21
+
match app.framework:
22
+
case "capacitor" | "cordova":
23
+
...
24
+
case "expo" | "react_native":
25
+
...
26
+
- case _ as unreachable:
27
+
- assert_never(unreachable)
28
+
+ case _:
29
+
+ ...
30
+
```
31
+
32
+
A value from a response that goes into a method argument, or into anything typed with the closed alias, must be narrowed first. A `match` on the known values narrows it, and so does a `TypeGuard` function. `==` and `in` do not narrow it under mypy:
`Release.conditions` is typed as a list of `ReleaseCondition | UnknownCondition`. A condition your client cannot read, such as one of a type newer than your client, arrives as an `UnknownCondition`. It keeps its `type`. Its other fields are in `model_extra`, under the API's camelCase names. Before, the whole call raised a pydantic `ValidationError`.
44
+
45
+
Code checked with mypy or pyright that handles every condition model needs a branch for `UnknownCondition`. A check of `condition.type` no longer narrows the model, so use `isinstance` or a class pattern:
46
+
47
+
```diff
48
+
match condition:
49
+
case AttributeCondition():
50
+
...
51
+
+ case UnknownCondition():
52
+
+ ...
53
+
```
54
+
55
+
The `conditions` argument of `apps.channels.releases.create` takes only the five known models. When a release holds an `UnknownCondition`, stop and update the client before you pass its conditions on. Never leave the condition out, since that widens the audience.
Copy file name to clipboardExpand all lines: CLAUDE.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,15 +73,16 @@ Run `uv run ruff format .` before every commit; the format check, lint, type che
73
73
- The body and the query are dicts whose keys are the API's camelCase names, written out, `{"isProtected": is_protected}`, so a name greps against `openapi.json`.
74
74
- Every path goes through `resolve_path` with the snapshot's template verbatim, `resolve_path("/v1/apps/{appId}", appId=app_id)`.
75
75
- A method returns a model or a list of models, as the API answers; a status-only answer returns `None` through `fetch_status`.
76
-
- A model is a `HotCodePushModel` named after the API's entity, its fields the snapshot's properties in snake_case: required ones without a default, nullable ones `X | None`, a relation `X | None = None`; a date-time is a `datetime`, an enum a `Literal`, an alias in `models.py` when two types share it.
76
+
- A model is a `HotCodePushModel` named after the API's entity, its fields the snapshot's properties in snake_case: required ones without a default, nullable ones `X | None`, a relation `X | None = None`; a date-time is a `datetime`, an enum the caller sends a `Literal`, an alias in `models.py` when two types share it.
77
+
- An enum a model reads from a response is that `Literal` or alias with `| str`, as in `Framework | str`, so a value newer than the client passes through. The `type` of a release condition picks the model, so it stays a closed `Literal`, and a condition the client cannot read, such as one of a type newer than the client, is read as an `UnknownCondition`.
77
78
- A query flag documented as `"true" | "false"` is a `bool`.
78
79
- After a resource's `list` method, an annotation writes `builtins.list`, since the method shadows the builtin in the class body.
79
80
- A method whose operation the document marks with `sessionAuth` carries ``An API token answers `forbidden`; sign in with a session.`` in its docstring; the contract test holds the note to the document.
80
81
81
82
## The OpenAPI snapshot
82
83
83
84
The API's `/openapi` document is the contract, and `openapi.json` is its committed snapshot, the same bytes as `hotcodepush-node`'s, so the package builds and CI checks without the API.
84
-
A schema change breaks `tests/test_openapi.py`, which calls every resource method once with every option it can send and answers it with the example of its operation's documented response: it fails when a method sends a path, method, query parameter, body field or content type the snapshot lacks, when it sends an `Idempotency-Key` where the operation documents none or none where it does, when a response property lands in a model's `model_extra` or fails its validation, when the session note and `sessionAuth` disagree, when a resource method has no call in `CALLS`, and when an operation has no method.
85
+
A schema change breaks `tests/test_openapi.py`, which calls every resource method once with every option it can send and answers it with the example of its operation's documented response: it fails when a method sends a path, method, query parameter, body field or content type the snapshot lacks, when it sends an `Idempotency-Key` where the operation documents none or none where it does, when a response property lands in a model's `model_extra` or fails its validation, when a model refuses a catalog value newer than the client, when the session note and `sessionAuth` disagree, when a resource method has no call in `CALLS`, and when an operation has no method.
Copy file name to clipboardExpand all lines: README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,8 @@ Every method takes keyword arguments and returns pydantic models with snake_case
34
34
Uploads take `bytes` or a file object with its `content_length` and stream it.
35
35
Creating calls send an `Idempotency-Key` and are retried. Pass `idempotency_key` to reuse one across your own retries.
36
36
A failed request raises a `HotCodePushError` with the API's `code`, `message`, `details` and the HTTP `status`. `code` is a `str`, so a code newer than your client passes through, and `ErrorCode` lists the codes this version knows.
37
+
A catalog field of a model, such as `App.framework`, is typed `Framework | str` for the same reason.
38
+
A release condition your client cannot read, such as one of a type newer than your client, is an `UnknownCondition`.
0 commit comments