-
Notifications
You must be signed in to change notification settings - Fork 191
Add global ruff linter; unify python/ onto repo-wide ruff #5726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2f75dbc
Add global ruff linter; unify python/ onto repo-wide ruff
denik bb8eff4
Drop redundant comment in python/pyproject.toml
denik 8853dc7
Keep python/ formatting at line-length 88 via python/ruff.toml
denik 8453bd8
Drop prose comment block from ruff.toml
denik 6da34ff
Expand ruff check to owned infra scripts and docs
denik 08e0c39
Lint all of python/ instead of listing its subdirs
denik d558ecf
Lint the whole repo with ruff, excluding fixtures and generated outputs
denik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ vars: | |
| # Absolute path so tasks with `dir:` (lint-go-tools, lint-go-codegen) can use it. | ||
| GO_TOOL: go tool -modfile={{.ROOT_DIR}}/tools/go.mod | ||
| EXE_EXT: '{{if eq OS "windows"}}.exe{{end}}' | ||
| # Pinned ruff (linter + formatter). Keep in sync with the version in | ||
| # .github/workflows/check.yml and python/Taskfile.yml. | ||
| RUFF: uvx ruff@0.15.17 | ||
| TEST_PACKAGES: ./acceptance/internal ./libs/... ./internal/... ./cmd/... ./bundle/... ./experimental/ssh/... . | ||
| ACCEPTANCE_TEST_FILTER: "" | ||
| # Single brace-expansion glob covering every //go:embed target in the repo, | ||
|
|
@@ -75,14 +78,29 @@ tasks: | |
| # speed; `./task all` uses the full variants. | ||
|
|
||
| lint: | ||
| desc: Lint all Go files (root + tools + codegen modules) | ||
| desc: Lint all Go files (root + tools + codegen modules) and Python scripts | ||
| cmds: | ||
| - task: lint-go | ||
| - task: lint-python | ||
|
|
||
| lint-q: | ||
| desc: Lint changed Go files in root module (diff vs main, with --fix) | ||
| desc: Lint changed Go files in root module (diff vs main, with --fix) and Python scripts | ||
| cmds: | ||
| - task: lint-q-go-root | ||
| - task: lint-python | ||
|
|
||
| lint-python: | ||
| desc: Lint first-party Python scripts with ruff | ||
| sources: | ||
| - "**/*.py" | ||
| - ruff.toml | ||
| cmds: | ||
| # Lints the whole repo; fixtures and generated outputs are skipped via | ||
| # `lint.exclude` / `extend-exclude` in ruff.toml. --no-cache: some excluded | ||
| # acceptance fixtures carry their own pyproject.toml/ruff.toml (config | ||
| # roots), so without it ruff writes a .ruff_cache into those checked-in | ||
| # dirs, polluting the goldens and breaking the acceptance tests. | ||
| - "{{.RUFF}} check --no-cache ." | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to do this selectively?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do what selectively? apply ruff to specific folder? or disable cache for specific folders? |
||
|
|
||
| # `golangci-lint run` typechecks, so it stops at go.mod boundaries. We have | ||
| # one task per Go module; `lint-go` composes them to cover the whole repo. | ||
|
|
@@ -166,14 +184,19 @@ tasks: | |
| deps: ['fmt-python', 'fmt-q-go', 'fmt-yaml'] | ||
|
|
||
| fmt-python: | ||
| desc: Format Python files | ||
| desc: Lint-fix and format Python files | ||
| sources: | ||
| - "**/*.py" | ||
| - ruff.toml | ||
| cmds: | ||
| # Pinned to match the version used by the `ruff format --check` step in | ||
| # Auto-fix the lint issues that ruff can fix (whole repo, minus lint.exclude); | ||
| # `|| true` so unfixable findings don't abort fmt (lint-python reports them). | ||
| # --no-cache: see lint-python (avoids polluting acceptance fixture goldens). | ||
| - "{{.RUFF}} check --no-cache --fix . || true" | ||
| # Pinned (via the RUFF var) to match the `ruff format --check` step in | ||
| # .github/workflows/check.yml — newer ruff versions reformat files that | ||
| # CI considers already formatted. | ||
| - "uvx ruff@0.15.17 format -n" | ||
| - "{{.RUFF}} format -n" | ||
|
|
||
| # `golangci-lint fmt` walks the filesystem and doesn't typecheck, so it | ||
| # formats files across all nested modules (tools/, bundle/internal/tf/codegen/) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #!/usr/bin/env python3 | ||
| import os, sys | ||
| import os | ||
| import sys | ||
|
|
||
| errors = 0 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| #!/usr/bin/env python3 | ||
| import os, sys | ||
| import os | ||
| import sys | ||
|
|
||
| errors = 0 | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| #!/usr/bin/env python3 | ||
| import json | ||
| import re | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly speaking is not provided by uvx but installed on demand, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, uvx downloads it when ran if not in its cache already.