Skip to content

Feat: Convert the binder's Kotlin-named stubs to pythonx stubs by the runtime's rule - #23

Merged
b-re-w merged 2 commits into
developfrom
work/stubs
Oct 2, 2026
Merged

b-re-w merged 2 commits into
developfrom
work/stubs

Conversation

@b-re-w

@b-re-w b-re-w commented Oct 2, 2026

Copy link
Copy Markdown
Member

Refs #12 (stays open: real input and py.typed still pending)

tools/gen_stubs.py turns python-multiplatform's Kotlin-named stubs into pythonx/compose/**/__init__.pyi, applying the same python_name / snake_case the runtime resolves names with:

  • functions, constants and parameters are renamed; receiver and anonymous __aN slots keep their names;
  • each explicit overload also becomes an @overload of its base name, which is what the runtime dispatcher answers to;
  • nested object stubs (Arrangement/) are converted one level down;
  • a package's own definitions (runtime.Composable) are carried over.

Feature added: the converter.
Test added: tests/test_stubs.py (8), run over a fixture holding the fake host's declarations. It includes a check that each stub signature equals the runtime inspect.signature. The tests were written alongside the tool, not before it. As failing-path evidence instead: disabling the parameter rename fails 2 tests, the overloads 1, the name rule 3.
Documentation corrected: SPEC S1.2 (partial) and baseline, PROJECT.md, guide baseline.
Not here: generated stubs for real Compose and py.typed. These need Kotlin-named stubs for Compose 1.11.1 from python-multiplatform, and object types better than int; both questions are with the ecosystem lead.

Environment Before After
No PythonMultiplatform checkout 43 passed, 45 skipped 50 passed, 46 skipped
../PythonMultiplatform 84 passed, 4 skipped 92 passed, 4 skipped

tools/check_guide.py: 0 findings.

b-re-w added 2 commits October 3, 2026 07:17
… runtime's rule

python-multiplatform's plugin now emits stubs under Kotlin names only, and its
Pythonic generator is gone (d00f413f). The Pythonic half is this package's.
tools/gen_stubs.py reads a directory of Kotlin-named stubs and writes
pythonx/compose/**/__init__.pyi for every manifest module:

- functions and constants are renamed with _reexport.python_name and
  parameters with snake_case -- the functions the runtime resolves names with,
  so an editor and the interpreter cannot disagree; receiver and anonymous
  __aN slots keep their names;
- each explicit overload also becomes an @overload of its base name, which is
  what the runtime dispatcher answers to;
- nested object stubs (Arrangement/) are converted one level down;
- a package's own definitions (runtime.Composable) are carried over, since a
  .pyi replaces what a checker knows about the module.

No stub is generated or shipped yet: that needs the Kotlin-named stubs for
Compose 1.11.1 from python-multiplatform, and object types better than int,
both asked of the ecosystem lead. #12 stays open.

feature added: tools/gen_stubs.py.
test added: tests/test_stubs.py (8) over a fixture holding the fake host's
declarations, including a check that each stub signature equals the runtime
inspect.signature. The tests were written alongside the tool, not before it;
as the failing-path evidence, disabling the parameter rename fails 2, the
overloads 1, the name rule 3.
documentation corrected: SPEC S1.2 and baseline, PROJECT.md, guide baseline.
Suite with ../PythonMultiplatform: 84 passed, 4 skipped -> 92 passed, 4
skipped. Without a checkout: 43 passed, 45 skipped -> 50 passed, 46 skipped.
check_guide.py: 0.

Refs #12
The previous commit wrote the same subtest figure into both rows of SPEC 0.
Without a checkout the suite runs 66 subtests, with one 72; and 46 tests,
not 45, skip without a checkout now that the stub test installs the binder.

documentation corrected: SPEC section 0.

Refs #12
@b-re-w
b-re-w merged commit cbd2d34 into develop Oct 2, 2026
@b-re-w
b-re-w deleted the work/stubs branch October 3, 2026 10:20
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