Format a Python function with proper indentation for TVMScript.
(self, _func_name: str, func_source: str, indent: int)
| 585 | return None |
| 586 | |
| 587 | def _format_python_function(self, _func_name: str, func_source: str, indent: int) -> str: |
| 588 | """Format a Python function with proper indentation for TVMScript.""" |
| 589 | lines = func_source.split("\n") |
| 590 | formatted_lines = [] |
| 591 | |
| 592 | for line in lines: |
| 593 | # Skip the function definition line if it's already properly indented |
| 594 | if line.strip().startswith("def ") or line.strip().startswith("@"): |
| 595 | # Keep decorators and function definition as is |
| 596 | formatted_lines.append(" " * indent + line.strip()) |
| 597 | else: |
| 598 | # Add proper indentation for the function body |
| 599 | formatted_lines.append(" " * indent + line.strip()) |
| 600 | |
| 601 | return "\n".join(formatted_lines) |
| 602 | |
| 603 | def show(self, style: str | None = None, black_format: bool | None = None, **kwargs) -> None: |
| 604 | """A sugar for print highlighted TVM script with Python function support. |
no test coverage detected