Repository navigation
Feat: Ship Pythonic stubs for Compose 1.11.1, generated by the runtime's own rule - #40
Merged
Merged
Conversation
…e's own rule python-multiplatform now publishes Kotlin-named stubs for real Compose as a CI artifact (kotlin-stubs, run 37077627980). tools/gen_stubs.py reads that zip in place -- it holds two paths that differ only in case, which macOS cannot extract (python-multiplatform #44) -- and writes pythonx/compose/**/__init__.pyi for every manifest module, plus py.typed: - names and parameters follow _reexport.python_name / snake_case, so an editor completes what the interpreter resolves; - stub classes keep their names and their extension members are renamed, but a method's Protocol __call__ keeps Kotlin keyword names, because the runtime does not translate a method's keywords yet (python-multiplatform #34); the header says so; - references into mapped Kotlin packages name the pythonx module; references into unmapped ones become Any; - a Kotlin object is a class in its parent stub (constants as ClassVar, functions as snake_case staticmethods) -- not a sub-package directory, which would be a namespace package at run time and shadow the object the re-export serves; both upstream layouts are read; - the second mapping of a package re-exports the first, so mypy sees one RowScope; material3 re-exports Column, Row and Spacer per [aliases]; - an object shadowed by a same-named function (Color, TextStyle, PaddingValues, TextUnit, ...) is left out, as at run time; constants named None are left out. tests/test_typing.py runs mypy against the committed stubs: correct code passes, a Kotlin-spelled keyword or name on a module function or method name fails, and importing every manifest module checks every stub. CI installs mypy. Drafted by a subagent in a worktree; reviewed here and re-run. feature added: generated stubs for 10 modules (385 kB) and py.typed. test added: 24 in test_stubs.py (including a regeneration check that skips without the zip), 7 in test_typing.py, 2 in test_wheel.py. Red before the generator change: 28 failed, 20 passed. Disabling each generator step fails between 1 and 11 tests. documentation corrected: SPEC S1.1/S1.2 and baseline, PROJECT.md, guide status/getting-started/index/concepts, README and README_ko. Suite against python-multiplatform ba4c6f49: 110 passed, 1 skipped -> 143 passed, 1 skipped. Without a checkout (worktree, no notebook): 54 passed, 57 skipped -> 84 passed, 60 skipped. check_guide.py: 0. Refs #12
test_typing.py made its temporary directory under .tmp/, which exists in a working checkout but not in a fresh one, so CI failed with FileNotFoundError. Both tests that use .tmp/ now create it first. defect fixed: tests assumed .tmp/ existed. Checked by running both modules with .tmp/ moved away: they pass. 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.
Closes #12
tools/gen_stubs.pyreads python-multiplatform'skotlin-stubsartifact (run 37077627980, Compose 1.11.1). It reads the zip in place, because two paths in it differ only in case (python-multiplatform #44). It writespythonx/compose/**/__init__.pyifor every manifest module, pluspy.typed.Conversion rules
Any.KotlinObject.Feature added: 10 stub files (385 kB) and
py.typed.Test added:
Red before the generator change: 28 failed. Disabling each step fails 1–11 tests.
CI: both jobs install mypy.
Documentation corrected: SPEC S1.1/S1.2, PROJECT.md, guide, both READMEs.
Upstream problems found (reported to the binder, not fixed here):
None:constant syntax error;colors: …ItemColorsis typedbool;Arrangement.spacedBy;Any.ba4c6f49The PR was drafted by a subagent in a worktree, then reviewed and re-run here.