[Mlir-commits] [mlir] [MLIR] [Python] Fixed the return type of static_typeid (PR #183021)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 24 01:52:00 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Sergei Lebedev (superbobry)

<details>
<summary>Changes</summary>

Previously it was unqualified, which led to undefined variable errors under nanobind stubgen.

---
Full diff: https://github.com/llvm/llvm-project/pull/183021.diff


2 Files Affected:

- (modified) mlir/include/mlir/Bindings/Python/IRCore.h (+3-2) 
- (modified) mlir/lib/Bindings/Python/IRAttributes.cpp (+2-1) 


``````````diff
diff --git a/mlir/include/mlir/Bindings/Python/IRCore.h b/mlir/include/mlir/Bindings/Python/IRCore.h
index e9669c4b2726d..4ee7fee49554c 100644
--- a/mlir/include/mlir/Bindings/Python/IRCore.h
+++ b/mlir/include/mlir/Bindings/Python/IRCore.h
@@ -967,7 +967,7 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteType : public BaseTy {
               (DerivedTy::pyClassName + std::string(" has no typeid."))
                   .c_str());
         },
-        nanobind::sig("def static_typeid(/) -> TypeID"));
+        nanobind::sig("def static_typeid(/) -> " MAKE_MLIR_PYTHON_QUALNAME("ir.TypeID"));
     cls.def_prop_ro("typeid", [](PyType &self) {
       return nanobind::cast<PyTypeID>(nanobind::cast(self).attr("typeid"));
     });
@@ -1110,7 +1110,8 @@ class MLIR_PYTHON_API_EXPORTED PyConcreteAttribute : public BaseTy {
               (DerivedTy::pyClassName + std::string(" has no typeid."))
                   .c_str());
         },
-        nanobind::sig("def static_typeid(/) -> TypeID"));
+        nanobind::sig(
+            "def static_typeid(/) -> " MAKE_MLIR_PYTHON_QUALNAME("ir.TypeID")));
     cls.def_prop_ro("typeid", [](PyAttribute &self) {
       return nanobind::cast<PyTypeID>(nanobind::cast(self).attr("typeid"));
     });
diff --git a/mlir/lib/Bindings/Python/IRAttributes.cpp b/mlir/lib/Bindings/Python/IRAttributes.cpp
index 370b9d8d6e062..e69e47ce804b9 100644
--- a/mlir/lib/Bindings/Python/IRAttributes.cpp
+++ b/mlir/lib/Bindings/Python/IRAttributes.cpp
@@ -425,7 +425,8 @@ void PyIntegerAttribute::bindDerived(ClassTy &c) {
       [](nb::object & /*class*/) {
         return PyTypeID(mlirIntegerAttrGetTypeID());
       },
-      nb::sig("def static_typeid(/) -> TypeID"));
+      nb::sig(
+          "def static_typeid(/) -> " MAKE_MLIR_PYTHON_QUALNAME("ir.TypeID")));
 }
 
 nb::object PyIntegerAttribute::toPyInt(PyIntegerAttribute &self) {

``````````

</details>


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


More information about the Mlir-commits mailing list