`experimental-inspect`: Add `stubtest` test in CI to ensure generated stubfiles match binary interfaces
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
There is no test asserting stubtest is happy, only a commented-out TODO at pytests/noxfile.py:49.
There are some issues though that would have to be fixed before simply enabling a stubtest test in CI:
-
pyo3_pytestsisn't importable in the stub layout.type_checkerdoescopytree("stubs", "pyo3_pytests"), making it a mixed-project source dir of only.pyifiles, so maturin generates no__init__.py,#[pymodule_init]never runs and no submodule is importable. Fine for the static-onlymypysession, fatal forstubtest. -
43 unrelated gaps remain once it is importable:
Count Gap 16 __all__is set at runtime by#[pymodule]but never emitted into the stubs15 submodules aren't declared in __init__.pyi;stubtestdoesn't accept the incomplete-module__getattr__as covering them6 @disjoint_baseisn't emitted for classes that can't be subclassed3 annotations,consts,exceptionaren't registered insys.modulesbypytests/src/lib.rs(fixture gap)1 Number.__pow__'smodulohas a runtime default the stub doesn't express1 the inner pyo3_pytests.pyo3_pytestsmodule has no.pyi
Two smaller adjacent defects, also left alone: slot parameters with a runtime default are emitted without one (__pow__'s modulo, __get__'s owner), and reflected operators (__radd__, __rpow__, …) exist at runtime but never reach the stubs.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the commented-out TODO in pytests/noxfile.py:49 and inspect the type_checker session's stubs-to-pyo3_pytests layout. Then read pytests/src/lib.rs and compare the generated stubs with the listed stubtest gaps, including submodules, all, disjoint bases, defaults, and reflected operators. Done means CI runs stubtest successfully without the documented gaps.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- backend, ci-cd, testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100