Skip to content

Add PEP 561 type stubs for chiavdf#366

Open
emlowe wants to merge 1 commit into
mainfrom
add-type-stubs
Open

Add PEP 561 type stubs for chiavdf#366
emlowe wants to merge 1 commit into
mainfrom
add-type-stubs

Conversation

@emlowe
Copy link
Copy Markdown
Contributor

@emlowe emlowe commented Jun 3, 2026

Summary

  • Package chiavdf as a proper PEP 561 module with py.typed and __init__.pyi
  • Move the pybind11 extension to private chiavdf._chiavdf and re-export the public API from chiavdf/__init__.py (import path unchanged for callers)
  • Add stubtest to the Ubuntu check job (build extension, then validate stubs against runtime)
  • Avoid cibuildwheel importing the source tree during wheel tests by temporarily renaming chiavdf/ (same pattern as other Chia native wheels)

Test plan

  • CI Check - Ubuntu 3.12 Intel passes (flake8, mypy, stubtest)
  • CI cibuildwheel matrix passes on Linux/macOS/Windows
  • After release, bump chiavdf in chia-blockchain and remove [mypy-chiavdf.*] ignore_missing_imports

Made with Cursor


Note

Low Risk
Changes are packaging, typing, and CI only; VDF logic is unchanged aside from renaming the extension module, with stubtest intended to catch API mismatches.

Overview
This PR makes chiavdf a PEP 561–typed package while keeping the public import path the same (from chiavdf import …).

The pybind11 extension is built as chiavdf._chiavdf instead of a top-level extension module; chiavdf/__init__.py re-exports the VDF API, and __init__.pyi plus py.typed document types for mypy and other checkers. setup.py / CMake / fastvdf.cpp are updated so the native target is _chiavdf.

CI on Ubuntu gains cmake/GMP install deps, extends flake8 and mypy to the chiavdf package, and runs stubtest after pip install .. cibuildwheel temporarily renames the source chiavdf/ tree during wheel tests so pytest uses the built wheel, not the checkout.

Reviewed by Cursor Bugbot for commit cdbc6d2. Bugbot is set up for automated code reviews on this repo. Configure here.

Move the pybind extension to a private chiavdf._chiavdf module and re-export
the public API from chiavdf/__init__.py with __init__.pyi and py.typed.
Run stubtest in CI after building the extension.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cdbc6d2. Configure here.

Comment thread pyproject.toml
@emlowe emlowe requested review from arvidn, richardkiss and wjblanke June 3, 2026 20:37
@emlowe emlowe marked this pull request as ready for review June 3, 2026 21:42
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.

1 participant