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)
| 574 | |
| 575 | |
| 576 | def stylify(code: str) -> str: |
| 577 | """ |
| 578 | Applies the ruff part of our `make style` command to some code. This formats the code using `ruff format`. |
| 579 | As `ruff` does not provide a python api this cannot be done on the fly. |
| 580 | |
| 581 | Args: |
| 582 | code (`str`): The code to format. |
| 583 | |
| 584 | Returns: |
| 585 | `str`: The formatted code. |
| 586 | """ |
| 587 | has_indent = len(get_indent(code)) > 0 |
| 588 | if has_indent: |
| 589 | code = f"class Bla:\n{code}" |
| 590 | formatted_code = run_ruff(code) |
| 591 | return formatted_code[len("class Bla:\n") :] if has_indent else formatted_code |
| 592 | |
| 593 | |
| 594 | def check_codes_match(observed_code: str, theoretical_code: str) -> int | None: |
no test coverage detected