[Mlir-commits] [mlir] [MLIR][Python] Support `has_trait` for operations (PR #188492)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Mar 25 20:27:45 PDT 2026


================
@@ -3963,7 +3964,13 @@ void populateIRCore(nb::module_ &m) {
              Args:
                callback: A callable that takes an Operation and returns a WalkResult.
                walk_order: The order of traversal (PRE_ORDER or POST_ORDER).
-               op_class: If provided, only operations of this type are passed to the callback.)");
+               op_class: If provided, only operations of this type are passed to the callback.)")
+      .def("has_trait", [](PyOperationBase &self, nb::type_object &traitCls) {
----------------
PragmaTwice wrote:

> we could punt moving to a classmethod

For `_OperationBase`, I think it can NOT be a classmethod. For `OpView`, it can.

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


More information about the Mlir-commits mailing list