Repository navigation
fix(python): export ScanFailure from the barrel and sync the type stub - #1141
Merged
Merged
Conversation
skip-changelog: test-only red commit; the behavior fragment lands with the implementation
The barrel now re-exports ScanFailure so callers can annotate what scan_failures() returns without reaching into dirsql._dirsql. The bundled stub gains ScanFailure, DirSQL.scan_failures, run_cli, and Table.on_file, all of which the bindings already define. PARITY.md's scan-failure claim now names where the Python type is importable from.
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.
Fixes #1140
PARITY.mdclaimed scan-failure reporting was at parity across all three SDKs, but the Python half had no public name: the binding definesScanFailureandDirSQL.scan_failuresreturns it, yet the barrel did not export it and the bundled type stub declared neither. A type checker sawDirSQLwith noscan_failuresat all.This is additive and changes no runtime behavior: a re-export, a stub correction, and a doc amendment.
What changed
packages/python/dirsql/__init__.pyre-exportsScanFailureand lists it in__all__, sofrom dirsql import ScanFailureworks the wayfrom dirsql import RowEventdoes.packages/python/dirsql/_dirsql.pyigainsScanFailure(path/message/__repr__),DirSQL.scan_failures() -> list[ScanFailure], andrun_cli(argv: list[str]) -> int.Table.on_file.PyTabledeclares#[pyo3(get)] on_file: Py<PyAny>(packages/python/src/lib.rs:36), so the attribute is readable at runtime but was invisible to a type checker. Added asCallable[[str], list[Row]], matching the constructor parameter the stub already declared. Every other registered binding (config_paths_from_argv,plan_config_extensions,select_loadable,plan_extension_path,ExtensionPlanEntry,__version__) was verified againstpy_dirsql_moduleand is already present and correctly typed.PARITY.md— the scan-failure bullet now names where each binding's type is importable from, and the Python type-information bullet listsScanFailure.Parity
Restores parity. Python's scan-failure surface now matches the TypeScript barrel export and Rust's
pub OnFileFailure. No drift introduced; the TypeScript and Rust surfaces are untouched.Red/green
The barrel surface test (
packages/python/dirsql/__init___test.py) went in first as its own commit (333d87f) and CI went red on exactly its assertion — run 35371156085,Unit tests (3.10 / 3.12 / 3.13):The implementation landed separately in 14a68b8.
Manual exercise
Built the binding (
uv run maturin develop --uvinpackages/python), then drove a real scan failure through the SDK against a real temp directory — a table whoseon_filehook raises on one of two files:The failing file is skipped, the good one is indexed, and the object imported from the package root is the same class the binding returns.
Type checker, on a file annotating the binding's return:
Negative control, to show
tyis actually resolving attributes off the stub rather than falling back toAny:Also
just preflight:preflight: 0 failing pair(s), 3 skipped.E2E Verification
packages/python/e2e-attestations/<branch>.jsonreceipt written ifpackages/pythonchanged (just e2e-attest-python)packages/ts/e2e-attestations/<branch>.jsonreceipt written ifpackages/tschanged (just e2e-attest-ts) — not owed;packages/rust/srcandpackages/tsare untouched, confirmed by thetypescript-sdk [typescript] e2e-verifygate passing injust preflightrather than by assumptioncargo build -p dirsql --features cli, thenjust e2e-attest-python(which runsjust test-e2e=cd packages/python && uv run python -m pytest tests/e2e/ -x -q)37 passed in 12.58s; receipt recorded atpackages/python/e2e-attestations/claude-1140-scan-failure-export.jsonChangelog / Migrations
<root>/<pkg>/changelog.d/for each changed package (or:skip-changelogtrailer on a commit with reason) —packages/python/changelog.d/2026-09-18-export-scan-failure.md(Added)<root>/<pkg>/migrations.d/(or: not required -- additive/bugfix only) — not required, purely additive