Fix Bokeh typing errors in visualization module - #17
Merged
Conversation
### Motivation - Mypy was failing on `starlingrt.visualize` because Bokeh public exports and overloads caused incorrect type complaints for widget imports and `figure` usage. - The histogram point data name collided with a later glyph renderer variable, creating typing/confusion risks in code and CustomJS args. ### Description - Replace widget imports from `bokeh.models.widgets.inputs` with the typed public exports via `from bokeh.models import FileInput, RangeSlider, Select, Slider, TextInput` to match Bokeh's typing surface. - Add `from typing import Any, cast` and define `bokeh_figure = cast(Any, figure)` then use `bokeh_figure(...)` where a typed-agnostic figure constructor is required to avoid mypy overload issues while preserving runtime behavior. - Rename histogram point return to `hist_points` (from `points`) and update usages passed into `CustomJS` to avoid colliding with the glyph renderer variable `points` used for plotting. - Change `CrosshairTool(overlay=[...])` lists to tuples `CrosshairTool(overlay=(...))` to satisfy the typed API for overlays in Bokeh. ### Testing - Ran `python -m mypy --ignore-missing-imports -p starlingrt` and it completed with no issues. - Ran `python -m pytest` and all tests passed (1 passed, 1 skipped).
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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.
Motivation
starlingrt.visualizebecause Bokeh public exports and overloads caused incorrect type complaints for widget imports andfigureusage.Description
bokeh.models.widgets.inputswith the typed public exports viafrom bokeh.models import FileInput, RangeSlider, Select, Slider, TextInputto match Bokeh's typing surface.from typing import Any, castand definebokeh_figure = cast(Any, figure)then usebokeh_figure(...)where a typed-agnostic figure constructor is required to avoid mypy overload issues while preserving runtime behavior.hist_points(frompoints) and update usages passed intoCustomJSto avoid colliding with the glyph renderer variablepointsused for plotting.CrosshairTool(overlay=[...])lists to tuplesCrosshairTool(overlay=(...))to satisfy the typed API for overlays in Bokeh.Testing
python -m mypy --ignore-missing-imports -p starlingrtand it completed with no issues.python -m pytestand all tests passed (1 passed, 1 skipped).Codex Task