[Mlir-commits] [mlir] [mlir:python] Add manual typing annotations to `mlir.register_*` functions. (PR #170627)

Ingo Müller llvmlistbot at llvm.org
Thu Dec 4 01:56:41 PST 2025


================
@@ -114,6 +118,10 @@ NB_MODULE(_mlir, m) {
           return typeCaster;
         });
       },
+      nb::sig("def register_type_caster(typeid: _mlir.ir.TypeID, *, "
+              "replace: bool = False) "
+              "-> typing.Callable[[typing.Callable[[T], U]], "
----------------
ingomueller-net wrote:

`Callable[[T], U]` is the type of the type caster. This could probably be made more precise but I wasn't sure about what exactly is allowed here.

The whole type could also be *less* precise by simplifying to `-> typing.Callable[[T], T]`. This wouldn't enforce the fact that the type caster is has to be `Callable` but still preserve the type of the annotated object.

https://github.com/llvm/llvm-project/pull/170627


More information about the Mlir-commits mailing list