diff options
| author | Dax Raad <[email protected]> | 2025-07-17 18:07:06 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-17 18:07:06 -0400 |
| commit | 23c30521d8a4040cb607a78aeb4c4fd674318dba (patch) | |
| tree | 13c3afdb45373b3e15273a0a2cc2a34aeb2ab588 | |
| parent | e681d610deca5a9a5510764132bd8bc32de941c2 (diff) | |
| download | opencode-23c30521d8a4040cb607a78aeb4c4fd674318dba.tar.gz opencode-23c30521d8a4040cb607a78aeb4c4fd674318dba.zip | |
only enable ruff if it seems to be used
| -rw-r--r-- | packages/opencode/src/format/formatter.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/opencode/src/format/formatter.ts b/packages/opencode/src/format/formatter.ts index 1c0c9721f..83e359f6f 100644 --- a/packages/opencode/src/format/formatter.ts +++ b/packages/opencode/src/format/formatter.ts @@ -105,7 +105,29 @@ export const ruff: Info = { command: ["ruff", "format", "$FILE"], extensions: [".py", ".pyi"], async enabled() { - return Bun.which("ruff") !== null + if (!Bun.which("ruff")) return false + const app = App.info() + const configs = ["pyproject.toml", "ruff.toml", ".ruff.toml"] + for (const config of configs) { + const found = await Filesystem.findUp(config, app.path.cwd, app.path.root) + if (found.length > 0) { + if (config === "pyproject.toml") { + const content = await Bun.file(found[0]).text() + if (content.includes("[tool.ruff]")) return true + } else { + return true + } + } + } + const deps = ["requirements.txt", "pyproject.toml", "Pipfile"] + for (const dep of deps) { + const found = await Filesystem.findUp(dep, app.path.cwd, app.path.root) + if (found.length > 0) { + const content = await Bun.file(found[0]).text() + if (content.includes("ruff")) return true + } + } + return false }, } |
