ci: verify type stubs match PyO3 bindings with mypy.stubtest#122
Open
ssmichael1 wants to merge 1 commit into
Open
ci: verify type stubs match PyO3 bindings with mypy.stubtest#122ssmichael1 wants to merge 1 commit into
ssmichael1 wants to merge 1 commit into
Conversation
The hand-written .pyi stubs had never been type-checked and had drifted from the compiled bindings — e.g. `quaternion.rotz(theta=0.5)` (what the stub advertised) raised TypeError at runtime because PyO3 named the arg `theta_rad`. Add a stubtest gate to the `python bindings test` CI job and bring the stubs back into agreement with the runtime. CI check: - New stubtest step + `mypy` in the `[test]` extra. Run with `--ignore-positional-only --ignore-disjoint-bases` plus python/stubtest_allowlist.txt, which suppresses only systematic PyO3 idioms (constructors, pickle dunders, native submodules, final classes, stub-only type aliases, __all__). No real drift is allowlisted. Stub build fixes (stubs now type-check): - Removed 22 illegal overload-implementation blocks across 5 .pyi files. - Reunited the `time.__add__` overload group split by other methods. - Added `_Time` alias to dodge the `time`-property annotation shadowing in satstate/propresult. Drift fixes (stub-only, no runtime change): - rotx/y/z theta->theta_rad, from_gps_week_and_second sec->seconds, sgp4 tm->time, satstate.propagate time->timedur, from_rotation_matrix mat->dcm; removed phantom as_gregorian(scale=); fixed sgp4_opsmode.improved; added itrfcoord.height, time.add_utc_days, weekday.Invalid. Keyword renames (public API — positional calls unaffected): - duration.from_hours/from_minutes/from_seconds: d -> hours/minutes/seconds - time.from_string s->string, from_unixtime t->unixtime, from_rfc3339 s->rfc3339, from_datetime tm->dt, strftime fmt->format, strptime (s,fmt)->(date_string,format) - kepler.from_pv (r,v)->(pos,vel) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What & why
The hand-written
.pyitype stubs had never been type-checked and had drifted from the compiled PyO3 bindings. The drift was user-visible: following the stub,quaternion.rotz(theta=0.5)raisedTypeErrorat runtime because PyO3 actually named the argumenttheta_rad. This adds amypy.stubtestgate to CI and brings the stubs back into agreement with the runtime.Not a release — the
CHANGELOGheading staysUnreleased; the keyword renames ride the next version bump.The CI check
python bindings testjob;mypyadded to the[test]extra.--ignore-positional-only --ignore-disjoint-bases+python/stubtest_allowlist.txt.__all__). No real drift is suppressed; stubtest errors on unused entries so the list stays honest.Stub build fixes (stubs now parse/type-check)
.pyifiles.time.__add__overload group that was split by other methods._Timealias to dodgetime-property annotation shadowing insatstate/propresult.Drift fixes — stub-only, no runtime change
rotx/y/z theta→theta_rad,from_gps_week_and_second sec→seconds,sgp4 tm→time,satstate.propagate time→timedur,from_rotation_matrix mat→dcm; removed phantomas_gregorian(scale=); fixedsgp4_opsmode.improved; addeditrfcoord.height,time.add_utc_days,weekday.Invalid.Keyword renames — public API (positional calls unaffected)
duration.from_hours/from_minutes/from_secondsdhours/minutes/secondstime.from_stringsstringtime.from_unixtimetunixtimetime.from_rfc3339srfc3339time.from_datetimetmdttime.strftimefmtformattime.strptimes,fmtdate_string,formatkepler.from_pvr,vpos,velVerification
stubtest:Success: no issues found in 10 modules(exit 0, no unused allowlist entries)cargo clippy --workspace --all-targets -- -D warnings: cleancargo fmt --all: appliedpython/orexamples/🤖 Generated with Claude Code