Skip to content

Commit 4e679ea

Browse files
authored
[MLIR] [python] Fixed the signature of _OperationBase.get_asm (#136676)
It claimed to return an `io.StringIO` or an `io.BytesIO`, but it did in fact return `str` or `bytes`.
1 parent 85b35a9 commit 4e679ea

File tree

1 file changed

+19
-12
lines changed
  • mlir/python/mlir/_mlir_libs/_mlir

1 file changed

+19
-12
lines changed

mlir/python/mlir/_mlir_libs/_mlir/ir.pyi

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ from __future__ import annotations
4545
import abc
4646
import collections
4747
from collections.abc import Callable, Sequence
48-
import io
4948
from pathlib import Path
50-
from typing import Any, BinaryIO, ClassVar, TypeVar, overload
49+
from typing import Any, BinaryIO, ClassVar, Literal, TypeVar, overload
5150

5251
__all__ = [
5352
"AffineAddExpr",
@@ -196,6 +195,19 @@ class _OperationBase:
196195
Detaches the operation from its parent block.
197196
"""
198197
def erase(self) -> None: ...
198+
199+
@overload
200+
def get_asm(
201+
binary: Literal[True],
202+
large_elements_limit: int | None = None,
203+
enable_debug_info: bool = False,
204+
pretty_debug_info: bool = False,
205+
print_generic_op_form: bool = False,
206+
use_local_scope: bool = False,
207+
assume_verified: bool = False,
208+
skip_regions: bool = False,
209+
) -> bytes: ...
210+
@overload
199211
def get_asm(
200212
self,
201213
binary: bool = False,
@@ -206,19 +218,14 @@ class _OperationBase:
206218
use_local_scope: bool = False,
207219
assume_verified: bool = False,
208220
skip_regions: bool = False,
209-
) -> io.BytesIO | io.StringIO:
221+
) -> str:
210222
"""
211-
Gets the assembly form of the operation with all options available.
223+
Returns the assembly form of the operation.
212224
213-
Args:
214-
binary: Whether to return a bytes (True) or str (False) object. Defaults to
215-
False.
216-
... others ...: See the print() method for common keyword arguments for
217-
configuring the printout.
218-
Returns:
219-
Either a bytes or str object, depending on the setting of the 'binary'
220-
argument.
225+
See the print() method for common keyword arguments for configuring
226+
the output.
221227
"""
228+
222229
def move_after(self, other: _OperationBase) -> None:
223230
"""
224231
Puts self immediately after the other operation in its parent block.

0 commit comments

Comments
 (0)