Skip to content

Type-check notebooks in CI and fix typing/library usage issues#74

Merged
darthtrevino merged 3 commits intomainfrom
chtrevin/ci/check_notebooks
May 4, 2026
Merged

Type-check notebooks in CI and fix typing/library usage issues#74
darthtrevino merged 3 commits intomainfrom
chtrevin/ci/check_notebooks

Conversation

@darthtrevino
Copy link
Copy Markdown
Member

Summary

Adds notebook type-checking to the CI pipeline and fixes the library-usage and typing issues it surfaced across the example notebooks.

A new check_notebooks poe task runs nbqa pyright over docs/notebooks/, and is wired into the top-level check sequence so notebook regressions are caught alongside the rest of the lint/type-check suite.

Changes

  • pyproject.toml: add nbqa + pyright notebook check task and include it in the aggregate check task.
  • docs/notebooks/*.ipynb: fix typing and API-usage issues flagged by pyright (imports, argument types, removed/renamed APIs, etc.).
  • benchmark_qed/autoe/utils/stats.py: minor typing fix uncovered while validating notebook usage.
  • uv.lock: refreshed for the added dev tooling.

Note on asyncio.run vs. top-level await

Several notebook cells previously used top-level await (which is valid in Jupyter). The verification path we adopted, nbqa pyright, concatenates all cells into a single synthetic .py module and runs the pyright CLI over it. In that flattened form, top-level await is reported as a hard parse error ("await" allowed only within async function), and pyright emits no rule name for this diagnostic — so it cannot be silenced via # pyright: ignore[<rule>] or [tool.pyright] settings. (Pyright's notebook-aware mode only exists in the language-server path used by Pylance, not the CLI; nbqa is the standard workaround for CLI-based notebook checking.)

To keep the CI check meaningful without resorting to bare # pyright: ignore comments scattered throughout, the affected calls have been rewritten to use asyncio.run(...). The notebooks still execute identically end-to-end; only the syntax around the async entry-points changed.

Validation

  • uv run poe check (includes check_notebooks) passes locally.
  • Notebooks were verified to still execute against the AP_news sample dataset.

Co-authored-by: Copilot <copilot@github.com>
@darthtrevino darthtrevino merged commit ea64ecc into main May 4, 2026
4 checks passed
@darthtrevino darthtrevino deleted the chtrevin/ci/check_notebooks branch May 4, 2026 16:16
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.

2 participants