Skip to content

fix(examples): resolve all mypy type errors #2047#2495

Open
joelpaulfernandez wants to merge 1 commit into
h2oai:mainfrom
joelpaulfernandez:fix/mypy-examples
Open

fix(examples): resolve all mypy type errors #2047#2495
joelpaulfernandez wants to merge 1 commit into
h2oai:mainfrom
joelpaulfernandez:fix/mypy-examples

Conversation

@joelpaulfernandez

Copy link
Copy Markdown

Summary

Fixes #2047.

Resolves all mypy errors in py/examples/ (209 → 0) without breaking existing functionality.

  • Add py/mypy.ini with disable_error_code = import-untyped for third-party packages lacking py.typed markers, and ignore_missing_imports for synth, h2o, altair, vega_datasets, plotly
  • Add pandas-stubs to requirements.txt for real pandas type checking instead of suppression
  • Relax pinned versions to >= in requirements.txt for Python 3.13 compatibility
  • Use Optional[T] for parameters that default to None (synth.py, table_pagination.py, table_pagination_pandas.py)
  • Switch to import h2o_wave.graphics as g in 8 graphics files — mypy 1.19 no longer resolves the submodule via __init__.py re-export
  • Replace deprecated pd.np with numpy directly (table_markdown_pandas.py)
  • Wrap bokeh.embed.json_item() second argument with ID() cast (plot_bokeh_*.py)
  • Add # type: ignore[attr-defined] for bokeh js_on_change dynamic attribute
  • Update tour.py type: ignore comment to cover str-unpack error code (mypy 1.19)
  • Fix pu(1)pu(close=True) in graphics_turtle.py, graphics_background.py
  • Fix update_ui value parameter type intfloat (background_progress.py)
  • Guard against None rows in db_todo.py list comprehension
  • Replace builtin any with Any from typing (plot_events_routing.py)
  • Rename shadowed loop variable filterscol_filters (table_pagination.py)

Test plan

  • mypy py/examples/ reports 0 errors
  • Static examples render correctly (splines, bokeh, turtle/spirograph)
  • Table pagination loads and page navigation works

- Add py/mypy.ini with disable_error_code=import-untyped and per-module
  ignore_missing_imports for synth, h2o, altair, vega_datasets, plotly
- Add pandas-stubs to requirements.txt for real pandas type checking
- Relax version pins to >= in requirements.txt for Python 3.13 compat
- Use Optional[T] for parameters defaulting to None (synth.py,
  table_pagination.py, table_pagination_pandas.py)
- Switch to `import h2o_wave.graphics as g` in 8 graphics files — mypy
  1.19 no longer resolves the submodule via __init__.py re-export
- Replace deprecated pd.np with numpy directly (table_markdown_pandas.py)
- Wrap bokeh json_item() second arg with ID() cast (plot_bokeh_*.py)
- Add type: ignore[attr-defined] for bokeh js_on_change dynamic attr
- Update tour.py type: ignore comment to cover str-unpack (mypy 1.19)
- Fix pu(1) -> pu(close=True) in graphics_turtle.py, graphics_background.py
- Fix update_ui value param type int -> float (background_progress.py)
- Guard against None rows in db_todo.py list comprehension
- Replace builtin any with Any from typing (plot_events_routing.py)
- Rename shadowed loop variable filters -> col_filters (table_pagination.py)
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.

Remove mypy errors from python examples

1 participant