[Mlir-commits] [mlir] [MLIR] [Python] Fixed the return type of static_typeid (PR #183021)
Sergei Lebedev
llvmlistbot at llvm.org
Tue Feb 24 01:51:27 PST 2026
https://github.com/superbobry created https://github.com/llvm/llvm-project/pull/183021
Previously it was unqualified, which led to undefined variable errors under nanobind stubgen.
>From ca71524ac72263f346ccdbe3465c708deba7df89 Mon Sep 17 00:00:00 2001
From: Sergei Lebedev <slebedev at google.com>
Date: Tue, 24 Feb 2026 09:49:52 +0000
Subject: [PATCH] [MLIR] [Python] Fixed the return type of static_typeid
Previously it was unqualified, which led to undefined variable errors under
nanobind stubgen.
---
mlir/include/mlir/Bindings/Python/IRCore.h | 5 +++--
mlir/lib/Bindings/Python/IRAttributes.cpp | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
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) {
More information about the Mlir-commits
mailing list