[Mlir-commits] [mlir] [MLIR] [Python] Added return type to `__repr__` in the adaptors (PR #182867)

Sergei Lebedev llvmlistbot at llvm.org
Tue Feb 24 01:32:47 PST 2026


================
@@ -569,10 +569,11 @@ class mlir_attribute_subclass : public pure_subclass {
         "isinstance",
         [isaFunction](MlirAttribute other) { return isaFunction(other); },
         nanobind::arg("other_attribute"), nanobind::sig(kIsinstanceSig));
-    def("__repr__", [superCls, captureTypeName](nanobind::object self) {
-      return nanobind::repr(superCls(self))
-          .attr("replace")(superCls.attr("__name__"), captureTypeName);
-    });
+    def("__repr__",
+        [superCls, captureTypeName](nanobind::object self) -> nanobind::str {
+          return nanobind::repr(superCls(self))
+              .attr("replace")(superCls.attr("__name__"), captureTypeName);
+        });
----------------
superbobry wrote:

It looks like `nanobind::repr` already returns a `str`: https://nanobind.readthedocs.io/en/latest/api_core.html#_CPPv4N8nanobind4reprE6handle.

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


More information about the Mlir-commits mailing list