Repository navigation
Feat: Convert the binder's Kotlin-named stubs to pythonx stubs by the runtime's rule - #23
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #12 (stays open: real input and
py.typedstill pending)tools/gen_stubs.pyturns python-multiplatform's Kotlin-named stubs intopythonx/compose/**/__init__.pyi, applying the samepython_name/snake_casethe runtime resolves names with:receiverand anonymous__aNslots keep their names;@overloadof its base name, which is what the runtime dispatcher answers to;Arrangement/) are converted one level down;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 runtimeinspect.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 thanint; both questions are with the ecosystem lead.../PythonMultiplatformtools/check_guide.py: 0 findings.