[Mlir-commits] [mlir] [MLIR] [Python] Added return type to `__repr__` in the adaptors (PR #182867)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Feb 23 20:32:17 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:
I think you need at least a `cast` or an **explicit** constructor to promote `nb::object` to a `nb::str`.
https://github.com/llvm/llvm-project/pull/182867
More information about the Mlir-commits
mailing list