Add type stubs for Brython browser module imports#45
Merged
Conversation
Add .pyi stubs for the browser package (browser/__init__.pyi, browser/ajax.pyi, browser/aio.pyi) covering all from-browser imports used in client-side Python. Fix pre-existing mypy issues in canvas2d_primitive_adapter.py exposed by the new stubs. Update tests in test_browser_typing_stubs.py. All 1065 tests pass (0 failures). Mypy errors in the changed files are pre-existing (647 errors on main, 576 on this branch — net improvement).
- Add missing DOMNode properties (id, src, outerHTML) and methods (replaceChild, setSelectionRange) to _dom.pyi - Make DOMNode.select() parameter optional for input text selection - Widen Window.setTimeout delay type to accept float - Add explicit type annotation for SvgRenderer._offscreen_surface - Use intermediate typed variables to avoid no-any-return in DrawableManager and TransformationsManager - Add type: ignore comments for intentional monkey-patching in tests - Replace os.getuid() with getattr fallback for Windows compatibility
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.
Summary
.pyitype stubs for the Brythonbrowserpackage (__init__.pyi,_dom.pyi,ajax.pyi,aio.pyi) understatic/client/typing/browser/from browser import Xnames used in client-side Python codecanvas2d_primitive_adapter.pyexposed by the new stubstest_browser_typing_stubs.pyTest results
Notes
Generated by SelfAssembler v13 run through Claw2PR Docker pipeline. The workflow completed research, planning, implementation, test_writing, test_execution (all green), and code_review phases successfully. Lint check oscillated on pre-existing mypy errors in the broader codebase.