[all-commits] [llvm/llvm-project] 6b67aa: [mlir:python] Improve `mlir_(attribute|type|value)...
Ingo Müller via All-commits
all-commits at lists.llvm.org
Tue Feb 18 23:08:11 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6b67aac31377992465c419b5a296f9a7ba8e7984
https://github.com/llvm/llvm-project/commit/6b67aac31377992465c419b5a296f9a7ba8e7984
Author: Ingo Müller <ingomueller at google.com>
Date: 2025-02-19 (Wed, 19 Feb 2025)
Changed paths:
M mlir/include/mlir/Bindings/Python/NanobindAdaptors.h
Log Message:
-----------
[mlir:python] Improve `mlir_(attribute|type|value)_subclass` for `nanobind`s `stubgen` (#127584)
This PR makes several improvements to the stubs that are created by
`mlir_(attribute|type|value)_subclass`.
First, the PR sets the `__module__` attribute of the classes generated
by the nanobind adaptors for attributes, types, and values (via
`mlir_(attribute|type|value)_subclass`). By default, the `__module__`
property is set to `importlib._bootstrap`, which isn't where we want the
new class to live. The new logic sets the property to the name of the
module provided as `scope` instead. This also makes nanobind's `stubgen`
generate stubs for those classes properly, which ignores classes whose
`__module__` does not correspond to the module it is generating stubs
for. This resolves #127518.
Second, the PR overwrites the function signatures generated by `stubgen`
to a format that uses the desired type names (e.g., `mlir.ir.Attribute`
instead of `MlirAttribute`).
Finally, the PR piggy-backs some minor doc and style improvements to
`PythonAdaptors.h`.
---------
Signed-off-by: Ingo Müller <ingomueller at google.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list