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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Feb 24 01:52:04 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);
+        });
----------------
PragmaTwice wrote:

But note that `str.attr("replace")(args..)` doesn't return `str`. the code still can't compile.

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


More information about the Mlir-commits mailing list