Skip to content

Commit 6be07dc

Browse files
committed
Docs: Point the pinned int refusal at the binder issue that reverses it
python-multiplatform #69 will box scalars in an Any slot and unbox them on read, so state(1) will work. The test that pins today's refusal and SPEC S5.4 / section 8 now name it, so whoever lands #69 knows what flips. documentation corrected: SPEC S5.4, section 8; a comment in test_app_root.py. Tests unchanged. Refs #11
1 parent d1c21a5 commit 6be07dc

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎docs/SPEC.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ Evidence: python-multiplatform #38 (`31c092f0`) binds generic functions and prop
217217
setters, and an `Any?` slot carries a Python object as itself, so `mutableStateOf(x)` is callable and
218218
the returned `MutableState`'s `.value` reads and writes. One consequence: the binder refuses an
219219
`int` in an `Any?` slot (it would cross as an object handle), so `state(1)` raises `TypeError` today
220-
and `pythonx` does not box it. Tests: `tests/test_app_root.py::TheLogic` (11) and `::TheStateFactory`
220+
and `pythonx` does not box it. python-multiplatform #69 makes the binder box scalars in an `Any`
221+
slot (bool, int, float, str) and unbox them on read; when it lands this refusal and its test flip. Tests: `tests/test_app_root.py::TheLogic` (11) and `::TheStateFactory`
221222
(4) run against a test-only fake state patched in for `_new_state`; `::TheBinderPath` (5) uses the
222223
real `_new_state` through the binder's Python layer and `tests/fake_host.py`, whose `mutableStateOf`
223224
and `MutableState.value` rows are shaped after #38 (`KotlinSurface.kt`, `PythonxAdapter.kt`), not
@@ -366,7 +367,7 @@ the binder lists no member that would win over these groups.
366367

367368
| Name | Notebook use | Note |
368369
|---|---|---|
369-
| `remember_saveable` | imported from `pythonx.compose.runtime`; state read/written with `getValue()` / `setValue()` | INTENT §5.1: `state(initial)` read and written through `.value` (S5.4, `partial`, #11; an `int` initial value is refused by the binder, #38); keeping a value across recreation is not provided |
370+
| `remember_saveable` | imported from `pythonx.compose.runtime`; state read/written with `getValue()` / `setValue()` | INTENT §5.1: `state(initial)` read and written through `.value` (S5.4, `partial`, #11; an `int` initial value is refused by the binder until python-multiplatform #69); keeping a value across recreation is not provided |
370371
| `DefaultCoroutineScope`, `MainCoroutineScope` | imported from `pythonx.compose.runtime` | INTENT §4.1, open |
371372
| `DefaultIcons` | `DefaultIcons.Add()` | INTENT §5.7: `Icons.Default` by alias, once python-multiplatform #37 binds `material-icons-core` |
372373
| `modifier` | lower-case instance from `pythonx.compose.ui` | INTENT §5.4: not provided; written `Modifier` |

‎tests/test_app_root.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def test_state_round_trips_through_the_binder(self):
261261
def test_an_int_state_is_refused_by_the_binder_not_papered_over(self):
262262
# `PythonxAdapter._coerce`: an int in an `Any?` slot would cross as an object handle, so the
263263
# binder refuses it. `state(1)` is therefore an error today; `pythonx` does not box it.
264+
# python-multiplatform #69 boxes scalars in `Any` slots: when it lands, this becomes a round trip.
264265
with self.assertRaises(TypeError) as raised:
265266
self.runtime.state(1)
266267
self.assertIn("int", str(raised.exception))

0 commit comments

Comments
 (0)