[Mlir-commits] [mlir] [MLIR][Python] Fix overly specific type annotation on PyValue.owner (PR #178003)

Rolf Morel llvmlistbot at llvm.org
Mon Jan 26 10:06:10 PST 2026


https://github.com/rolfmorel updated https://github.com/llvm/llvm-project/pull/178003

>From df56e495b8c6e2f8fff11745e53d351e1cfa9257 Mon Sep 17 00:00:00 2001
From: Rolf Morel <rolf.morel at intel.com>
Date: Mon, 26 Jan 2026 17:52:55 +0000
Subject: [PATCH 1/2] [MLIR][Python] Fix overly specific type annotation on
 PyValue.owner

---
 mlir/lib/Bindings/Python/IRCore.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index eb00363a54034..bea2ed4d3229f 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -4537,7 +4537,7 @@ void populateIRCore(nb::module_ &m) {
           kDumpDocstring)
       .def_prop_ro(
           "owner",
-          [](PyValue &self) -> nb::typed<nb::object, PyOpView> {
+          [](PyValue &self) -> nb::typed<nb::object, std::variant<PyOpView, PyBlock>> {
             MlirValue v = self.get();
             if (mlirValueIsAOpResult(v)) {
               assert(mlirOperationEqual(self.getParentOperation()->get(),

>From c44a7ef4d2a21fd8ba2fdcf64a1d3def77bd30f9 Mon Sep 17 00:00:00 2001
From: Rolf Morel <rolf.morel at intel.com>
Date: Mon, 26 Jan 2026 17:59:44 +0000
Subject: [PATCH 2/2] Format fix

---
 mlir/lib/Bindings/Python/IRCore.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index bea2ed4d3229f..54d5a15b92bf0 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -4537,7 +4537,8 @@ void populateIRCore(nb::module_ &m) {
           kDumpDocstring)
       .def_prop_ro(
           "owner",
-          [](PyValue &self) -> nb::typed<nb::object, std::variant<PyOpView, PyBlock>> {
+          [](PyValue &self)
+              -> nb::typed<nb::object, std::variant<PyOpView, PyBlock>> {
             MlirValue v = self.get();
             if (mlirValueIsAOpResult(v)) {
               assert(mlirOperationEqual(self.getParentOperation()->get(),



More information about the Mlir-commits mailing list