[Mlir-commits] [llvm] [mlir] [MLIR][Python] enable type stub auto-generation (PR #155741)

Ingo Müller llvmlistbot at llvm.org
Wed Sep 3 00:01:29 PDT 2025


ingomueller-net wrote:

This is awesome!

Do we know if the generated stubs are correct? I have set up a [CI job](https://github.com/substrait-io/substrait-mlir-contrib/blob/1e6f422/.github/workflows/build_and_test.yml#L113-L119) for a small MLIR project that uses `pyright` to check the types and it took me quite some effort to make that pass. From memories, I had to define some [signatures](https://github.com/substrait-io/substrait-mlir-contrib/blob/1e6f422/python/SubstraitDialects.cpp#L81-L84) by hand because stubgen didn't generate the full module prefix of the types and a file with fix-up [patterns](https://github.com/substrait-io/substrait-mlir-contrib/blob/1e6f422/python/CMakeLists.txt#L92) because either `__str__` or `__repr__` of some enum class wasn't generated with the correct signature. I now think that the manual signatures [might not be necessary](https://github.com/substrait-io/substrait-mlir-contrib/issues/171) and could instead be made correct with a few generic patterns but I haven't tried yet. TL;DR: I think we should make sure that the annotations from stubgen are correct; otherwise, their usefulness might be quite limited and actually be worse than the manually written ones.

Also, maybe we can ask the nanobind devs if they have an estimate on when the new release comes out and wait for that to happen.

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


More information about the Mlir-commits mailing list