[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 21:07:37 PST 2026
================
@@ -652,11 +653,12 @@ class mlir_type_subclass : public pure_subclass {
"isinstance",
[isaFunction](MlirType other) { return isaFunction(other); },
nanobind::arg("other_type"), nanobind::sig(kIsinstanceSig));
- def("__repr__", [superCls, captureTypeName](nanobind::object self) {
- return nanobind::cast<std::string>(
- nanobind::repr(superCls(self))
- .attr("replace")(superCls.attr("__name__"), captureTypeName));
- });
+ def("__repr__",
+ [superCls, captureTypeName](nanobind::object self) -> nanobind::repr {
+ return nanobind::cast<std::string>(
+ nanobind::repr(superCls(self))
+ .attr("replace")(superCls.attr("__name__"), captureTypeName));
+ });
----------------
PragmaTwice wrote:
```suggestion
def("__repr__",
[superCls, captureTypeName](nanobind::object self) {
return nanobind::cast<std::string>(
nanobind::repr(superCls(self))
.attr("replace")(superCls.attr("__name__"), captureTypeName));
});
```
https://github.com/llvm/llvm-project/pull/182867
More information about the Mlir-commits
mailing list