Skip to content

Commit bd82a26

Browse files
authored
fix: make JsonSerializable type alias read-only (#1072)
Bumping `ty` to 0.0.83 fails type-check: it rejects e.g. `list[dict[str, int]]` as `JsonSerializable` because `list`/`dict` are invariant. Fix: `JsonSerializable` uses read-only `Mapping`/`Sequence`, so callers can keep passing plain dicts and lists. The alias is only used for inputs that get serialized. The lock bumps only `ty` to 0.0.83 so CI proves the fix; unit tests pass; also clears the `push_items` error in apify-sdk-python.
1 parent 227e47f commit bd82a26

2 files changed

Lines changed: 23 additions & 22 deletions

File tree

‎src/apify_client/types.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from collections.abc import Mapping, Sequence
34
from datetime import timedelta
45
from typing import Literal
56

@@ -38,7 +39,7 @@
3839
matching the Apify API spelling.
3940
"""
4041

41-
JsonSerializable = dict[str, 'JsonSerializable'] | list['JsonSerializable'] | str | int | float | bool | None
42+
JsonSerializable = Mapping[str, 'JsonSerializable'] | Sequence['JsonSerializable'] | str | int | float | bool | None
4243
"""Recursive type for JSON-serializable values - primitives plus objects and arrays with JSON-serializable contents.
4344
4445
Based on the definition discussed in https://github.com/python/typing/issues/182.

‎uv.lock‎

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)