Applies the ruff part of our `make style` command to some code. This formats the code using `ruff format`. As `ruff` does not provide a python api this cannot be done on the fly. Args: code (`str`): The code to format. Returns: `str`: The formatted code.
(code: str)
| 101 | |
| 102 | |
| 103 | def stylify(code: str) -> str: |
| 104 | """ |
| 105 | Applies the ruff part of our `make style` command to some code. This formats the code using `ruff format`. |
| 106 | As `ruff` does not provide a python api this cannot be done on the fly. |
| 107 | |
| 108 | Args: |
| 109 | code (`str`): The code to format. |
| 110 | |
| 111 | Returns: |
| 112 | `str`: The formatted code. |
| 113 | """ |
| 114 | has_indent = len(get_indent(code)) > 0 |
| 115 | if has_indent: |
| 116 | code = f"class Bla:\n{code}" |
| 117 | formatted_code = run_ruff(code) |
| 118 | return formatted_code[len("class Bla:\n") :] if has_indent else formatted_code |
| 119 | |
| 120 | |
| 121 | def is_copy_consistent(filename, overwrite=False): |
no test coverage detected