(ruff_bin: str, cmd_args: list[str], filename: str, config: Path)
| 31 | |
| 32 | |
| 33 | def run_ruff(ruff_bin: str, cmd_args: list[str], filename: str, config: Path) -> list[str]: |
| 34 | # XXX: `--no-cache` is important when we run ruff in source root and don't want to pollute arcadia |
| 35 | cmd = [ruff_bin, *cmd_args, '--no-cache', '--config', config, filename] |
| 36 | res = subprocess.run( |
| 37 | cmd, |
| 38 | capture_output=True, |
| 39 | encoding='utf8', |
| 40 | errors='replace', |
| 41 | env=dict(os.environ.copy(), RUFF_OUTPUT_FORMAT='concise'), |
| 42 | # When config is passed through `--config`, `exclude` starts searching from cwd |
| 43 | # so set cwd to config cwd to mimic behavior of autodiscovery. |
| 44 | # Note that it stops being accurate when `extend` is used. |
| 45 | # https://docs.astral.sh/ruff/configuration/#config-file-discovery |
| 46 | cwd=os.path.dirname(config), |
| 47 | ) |
| 48 | return res.stdout.splitlines(keepends=True) if res.returncode else [] |
| 49 | |
| 50 | |
| 51 | def process_file( |
no test coverage detected