Repository navigation
ci: stubtest holds the Python type stubs to the built wheel, and a script lists the stubs' breaking changes (#873) - #913
Conversation
…ript lists the stubs' breaking changes (#873)
…File's constructor as pyo3 builds it (__new__, final)
…, and the return-shape aliases exist at runtime
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e87cb4c5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…and a removed __version__, and the dev lockfile carries mypy
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb14c70cb2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ng and re-exports, and matches *args and setters by role
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b902690c81
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: The type stubs match the built wheel | ||
| if: runner.os == 'Linux' | ||
| run: python3 -m mypy.stubtest rvt |
There was a problem hiding this comment.
Run the compatibility checker in CI
The inspected semver job still invokes only tools/ci/semver-gate.sh, while this new wheel step runs stubtest, which compares the head wheel with the head stub and cannot detect compatibility against the base revision. A repo-wide search finds no invocation of python-api-compat.py, so removing a Python method or required parameter still passes every CI gate; invoke this script from the semver job with the base and head stubs.
Useful? React with 👍 / 👎.
| positional = a.posonlyargs + a.args | ||
| defaults = [None] * (len(positional) - len(a.defaults)) + [ast.unparse(d) for d in a.defaults] | ||
| kinds = ["positional-only"] * len(a.posonlyargs) + ["positional"] * len(a.args) | ||
| out = [(p.arg, k, d) for p, k, d in zip(positional, kinds, defaults)] |
There was a problem hiding this comment.
Include annotations in compatibility signatures
The signature representation retains only parameter names, kinds, and defaults, dropping each parameter annotation and the function return annotation. Consequently, a stub change such as def f(x: object) -> str to def f(x: str) -> int exits successfully even though existing typed callers and consumers are no longer compatible; preserve and compare annotations as part of each callable signature.
Useful? React with 👍 / 👎.
| for j, (hname, hkind, hdefault) in enumerate(head_params): | ||
| if hdefault is not None or (hkind == "positional-only" and j < len(base_params)): | ||
| continue | ||
| if hname not in base_names: | ||
| found.append(f"{name}: new parameter {hname} has no default") |
There was a problem hiding this comment.
Reject inserted required positional-only parameters
A new positional-only parameter is unconditionally treated as an existing slot whenever its index is below the old parameter count. For example, comparing def f(x, /) with def f(y, x, /) exits successfully: the old slot is falsely matched to y, and this exemption suppresses the new-required-parameter report, although every existing f(value) call now fails because x is missing.
Useful? React with 👍 / 👎.
| else: | ||
| out[name] = (kind, [signature], decorators) | ||
| elif isinstance(node, ast.ClassDef) and public(node.name): | ||
| out[prefix + node.name] = ("class", None) |
There was a problem hiding this comment.
Preserve class bases in the collected API
Every class is reduced to the same ("class", None) entry, so changing class Child(Base) to class Child passes when both class names and their directly declared members remain. Existing callers then lose inherited methods and Child is no longer assignable to or recognized as Base; retain and compare the base-class expressions when collecting classes.
Useful? React with 👍 / 👎.
| out += [(p.arg, "keyword", None if d is None else ast.unparse(d)) for p, d in zip(a.kwonlyargs, a.kw_defaults)] | ||
| if a.kwarg: | ||
| out.append(("**", "variadic", "")) | ||
| return [p for p in out if p[0] not in ("self", "cls")] |
There was a problem hiding this comment.
Strip only the implicit receiver parameter
Filtering every parameter named self or cls also removes legitimate callable arguments rather than just the leading instance or class receiver. For example, changing def register(self, cls) to def register(self) exits successfully even though calls such as obj.register(MyType) now fail; make receiver removal depend on the callable's binding and position.
Useful? React with 👍 / 👎.
…onours SOURCE_DATE_EPOCH (#873) (#926) ## Summary `RELEASE.md` promises the output formats are written deterministically, and nothing checked it. A new CLI test runs every shipped writer twice on the same file and requires the same bytes. The one thing that differed, the export time an IFC records, is now set by `SOURCE_DATE_EPOCH`. ## Motivation S2 of the 1.0 criteria (#873) needs a check on each stable surface. The crate, the Python stubs, the wasm bindings and the CLIs' JSON got theirs in #910, #913 and #915; the output formats had validity checks (IfcOpenShell, the glTF container, the schedule columns) but none for the determinism `RELEASE.md` names. The IfcOpenShell witness writes `"deterministic": true` as a constant, not a measurement. ## Changes - `src/bin/rvt_ifc.rs`: reads `SOURCE_DATE_EPOCH` (Unix seconds, the reproducible-builds convention) and passes it to `write_step_with_options`; unset or empty keeps the wall-clock time, anything else that is not a number is refused before the file is opened. The help mentions it, and the module doc and `about` no longer say the export is document-level only. - `tests/reproducible_outputs.rs` (class `cli`): `rvt-ifc`, `rvt-gltf`, `rvt-sheet`, `rvt-schedule` and `rvt-schedule --schedule rooms`, twice each, same bytes, on the tier-1 project and on `Revit_IFC5_Einhoven.rvt` when `RVT_PROJECT_CORPUS_DIR` has it (tier 2). A second test checks the epoch reaches the `FILE_NAME` header and `IfcOwnerHistory`, and that a malformed value fails naming the variable. - `docs/user-guide.md` (Export IFC), `RELEASE.md` (Output formats row), `docs/release-1.0-criteria.md` (S2 passed, with what each check is), `CHANGELOG.md`. ## Testing CI runs the new target; no build on this machine. The measured result is the test itself: the same bytes from two runs of each writer, on a synthetic and a real file. - [ ] `tools/check-local.sh` passes: left to CI - [x] Verified end to end: the test runs the built CLIs on the committed tier-1 file and on Einhoven (magnetar-io/revit-test-datasets, MIT) in tier 2 - [x] IFC exporter: the IFC body is unchanged; only the header and owner-history time can differ, and only when `SOURCE_DATE_EPOCH` is set. Witness observations hash entity counts, relations and storeys, so they do not move - N/A: performance ## Audit-honesty checklist - [x] Docs reflect the state after this PR - [x] No limitation resolved beyond the check itself - [x] No new limitation - [x] Commit message says what and why - [x] No emojis - [x] No private paths - N/A: not a format finding ## Legal and contribution hygiene - [x] Apache-2.0 - [x] No Autodesk proprietary content - [x] No new fixtures ## Breaking changes None. Without `SOURCE_DATE_EPOCH`, `rvt-ifc` writes what it wrote before. ## Screenshots or output samples With `SOURCE_DATE_EPOCH=1700000000` the header reads `FILE_NAME('…','2023-11-14T22:13:20',…)` and the owner history ends `,1700000000);`. ## Related issues Refs #873 (S2)
Summary
The Python half of S2 in #873. mypy's stubtest now fails the Linux wheel job when the built wheel and
python/rvt/__init__.pyidisagree.tools/ci/python-api-compat.pylists the breaking changes between two versions of those stubs. With stubtest keeping the stubs true, a diff of the stubs is a diff of the Python API. The script is wired into thesemver checksjob of #910 once that lands, under the same!rule as the crate.Changes
tools/ci/requirements-test.{in,txt}: mypy 2.4.0, hash-pinned. Recompiled with the uv command at the file's top; only mypy and its dependencies were added..github/workflows/ci.yml, jobpython-wheel: "The type stubs match the built wheel" runspython3 -m mypy.stubtest rvton Linux after the pytest suite, against the installed wheel.tools/ci/python-api-compat.py <base.pyi> <head.pyi>: walks both stubs withastand reports a public name that is removed or changed kind, a parameter that is removed, renamed, moved or made keyword-only, a parameter that lost its default, a new parameter without one, and a TypedDict key removed (a returned dict's shape). It exits 1 when there is any.What stubtest found (first run, 30 errors, four distinct problems), fixed here
rvt.FileMetadatawas a stub-only alias, sofrom rvt import FileMetadatatype-checked but failed at runtime.python/rvt/__init__.pynow defines it astyping.Dict[str, Any], since the wheel supports Python 3.8, wheredict[str, Any]cannot be evaluated.RevitFile's constructor is pyo3's__new__, while the stub declared__init__. The stub now declares__new__with the same parameters, andpython-api-compat.pytreats either spelling as the constructor, so this correction is not reported as a removal.RevitFilecannot be subclassed at runtime and is a disjoint base, so the stub marks it@finaland@disjoint_base.src/python.rsas the source of truth; it isrvt-py/src/lib.rs.The second run, with stubtest checking the runtime module too, found two more, also fixed here:
basic_file_info_json_strict,schema_diagnostics,read_adocument_strictandread_adocument_lossy.TypedSchemaSummary,TypedField,TypedADocument,TypedDecodedElement,TypedElementCounts) did not exist at runtime, so importing one failed likeFileMetadatadid.python/rvt/__init__.pydefines each withtypinggenerics.Every other method's signature matched the wheel.
Testing
python-api-compat.py, run locally on the current stub against itself, reports nothing and exits 0. Against a copy that renamesread_adocumentand dropswrite_ifc'smodedefault, it reports both and exits 1.tools/check-local.sh: N/A, CI and tooling only.Audit-honesty checklist
Legal and contribution hygiene