The GitHub Actions job "CI" on tvm-ffi.git/2026-03-01/c-class-stubgen has 
succeeded.
Run started by GitHub user junrushao (triggered by junrushao).

Head commit for run:
6514c3da3bc420925ed28486611cedf1ab669806 / Junru Shao <[email protected]>
feat(python): wire __init__ from C++ reflection in register_object and stubgen

Architecture:
- `stub/utils.py`: New `InitFieldInfo` and `ObjectInfo.gen_init()` walk the
  TypeInfo parent chain to collect `c_init/c_kw_only/c_has_default` flags per
  field, emitting typed `__init__` stubs via `_gen_auto_init` (KWARGS protocol)
  or `_gen_c_init` (positional pass-through from `__c_ffi_init__`).
- `stub/codegen.py`: `generate_object()` now calls `gen_init()` and injects
  the result into the `TYPE_CHECKING` block before method stubs.
- `registry.py`: `register_object._register()` calls `_install_init(cls,
  enabled=True)` after `_add_class_attrs`, wiring `__init__` → `__ffi_init__`
  for any class whose C++ `ObjectDef` registered `refl::init()`.
- `_install_init` with `enabled=True` and no `__ffi_init__` now returns silently
  instead of installing a TypeError guard — backward-compatible for `Object()`
  and unregistered subclasses. The `enabled=False` guard (used by
  `@c_class(init=False)`) is unchanged.
- Removed duplicate `_install_init` definition that shadowed the primary one.

Public Interfaces:
- `register_object` now auto-wires `__init__` when C++ `__ffi_init__` exists;
  previously only `@c_class` did this.
- `core.pyi`: Added `TypeField.c_init`, `c_kw_only`, `c_has_default` and
  `TypeInfo.type_ancestors` stubs.
- Slots docstrings updated: recommend `__slots__ = ("__dict__",)` instead of
  the removed `slots=False` metaclass keyword.

UI/UX:
- none

Behavioral Changes:
- Registered classes with `__ffi_init__` (non-auto-init) get
  `__init__ = __ffi_init__` automatically — fixes `IntPair(1, 2)` in
  `examples/python_packaging`.
- Classes without `__ffi_init__` keep default `object.__init__` behavior.
- 30 unnecessary `ty: ignore` comments removed after stubgen generates proper
  `__init__` signatures.

Docs:
- `Object` docstring in `object.pxi` and `register_object` docstring in
  `registry.py` updated for slots guidance.
- `_make_init` / `_make_init_signature` docstrings expanded with field-walk
  and reordering details.

Tests:
- Executed: pre-commit (ruff check, ruff format, ty check, cython-lint,
  clang-format, ASF headers) — all passed.
- Python and C++ tests require a full build (not run here).

Untested Edge Cases:
- stubgen `_gen_c_init` on packages whose shared library is not loaded at
  stubgen time (the metadata would be unavailable; no crash, just no `__init__`
  emitted).
- Interaction of auto-wired `__init__` with `__init_subclass__` hooks on
  deeply nested Object hierarchies.

Report URL: https://github.com/apache/tvm-ffi/actions/runs/22552380460

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to