The GitHub Actions job "mainline-only" on tvm-ffi.git/main has failed. Run started by GitHub user tqchen (triggered by tqchen).
Head commit for run: e5f3af7bb83e6461c45d08117e4eaabe51add3b1 / Junru Shao <[email protected]> feat(python): reimplement c_class as register_object + structural dunders (#488) ## Summary Rewrite the `@c_class` decorator from a thin `register_object` pass-through into a `dataclass`-style decorator that combines FFI type registration with structural dunder methods derived from C++ reflection metadata. - **`@c_class` now installs structural dunders** — `__init__`, `__repr__`, `__eq__`/`__ne__`, `__hash__`, and ordering operators (`__lt__`, `__le__`, `__gt__`, `__ge__`) — all delegating to the corresponding C++ recursive operations (`RecursiveEq`, `RecursiveHash`, `RecursiveLt`, etc.). - **`@dataclass_transform` decorator** added for IDE/type-checker support (pyright, mypy). - **Migrated all test objects** in `tvm_ffi.testing` from `@register_object` to `@c_class`. ## Architecture - `c_class.py`: decorator accepts `init`, `repr`, `eq`, `order`, `unsafe_hash` parameters. Delegates to `register_object` + `_install_dataclass_dunders`. - `registry.py`: `_install_dataclass_dunders` installs dunders on class; `_install_init` synthesizes reflection-based `__init__` or guard; `_make_init` / `_make_init_signature` builds `inspect.Signature` from C++ field metadata (respecting `kw_only`, `has_default`, `c_init` traits). `_is_comparable` centralises the bidirectional isinstance guard. - Each installed dunder checks `cls.__dict__` before setting, preserving user-defined overrides. - `__eq__`/`__ne__`/ordering return `NotImplemented` for unrelated types, following Python data model conventions. ## Public Interfaces - `@c_class(type_key, *, init, repr, eq, order, unsafe_hash)` — new keyword arguments; old usage `@c_class("key")` continues to work with sensible defaults (`init=True`, `repr=True`, others off). - No breaking changes — `eq`, `order`, `unsafe_hash` default to `False`. ## Test Plan - [x] New `test_dataclass_c_class.py` (26 tests): custom init preservation, auto-generated init with defaults, structural equality (reflexive, symmetric), hash (dict key, set dedup), ordering (reflexive, antisymmetric), different-type returns `NotImplemented`, subclass equality, `kw_only` from C++ reflection, `init_subset`, derived-derived defaults. - [x] Renamed `test_copy.py` → `test_dataclass_copy.py` with additional cycle/Shape coverage and `deep_copy.cc` branch-coverage tests. - [x] `uv run pytest -vvs tests/python` — 960 passed, 23 skipped, 1 xfailed. - [x] `sphinx-build -W --keep-going -b html docs docs/_build/html` — build succeeded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Report URL: https://github.com/apache/tvm-ffi/actions/runs/22528008656 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
