-
Notifications
You must be signed in to change notification settings - Fork 110
Add Ruff and pre-commit checks #1198
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
+249
−4
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7b93454
FEAT: Add Ruff and pre-commit checks.
genedan 0a4bf0d
FEAT: Add Ruff and pre-commit checks.
genedan 040d6b2
FEAT: Add Ruff and pre-commit checks.
genedan 41cfc9d
FEAT: Add Ruff workflow.
genedan 439c6d4
FIX: Apply bugbot fixes.
genedan 56b68bb
TST: Deliberately push a file that fails the Ruff check.
genedan 5e1ffdc
TST: Deliberately push a file that fails the Ruff check.
genedan 72d82a4
TST: Deliberately push a file that fails the Ruff check.
genedan 8e94531
FIX: Ruff should only make one comment per fix in the PR changes sect…
genedan 2d25c15
FIX: Apply bugbot fix.
genedan f40ee9d
FIX: Clean up test_constant.py.
genedan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: Ruff | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - '**' | ||
|
|
||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: ruff check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Determine changed Python files | ||
| id: changed | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| base="origin/${{ github.event.pull_request.base.ref }}" | ||
| else | ||
| base="${{ github.event.before }}" | ||
| # New branch or force-push: 'before' may not exist locally (or be all-zeros). | ||
| if ! git cat-file -e "$base" 2>/dev/null; then | ||
| base="HEAD^" | ||
| git cat-file -e "$base" 2>/dev/null || base="" | ||
| fi | ||
| fi | ||
|
|
||
| if [ -z "$base" ]; then | ||
| files=$(git ls-files '*.py' | xargs) | ||
| else | ||
| files=$(git diff --name-only --diff-filter=ACMR "$base"...HEAD -- '*.py' | xargs) | ||
| fi | ||
|
|
||
| echo "files=$files" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Install uv | ||
| if: steps.changed.outputs.files != '' | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| version: "latest" | ||
|
|
||
| - name: Run ruff | ||
| if: steps.changed.outputs.files != '' | ||
| run: | | ||
| uvx ruff@0.16.1 check --config lint.per-file-ignores={} --output-format=github ${{ steps.changed.outputs.files }} |
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| default_install_hook_types: [pre-commit, pre-push] | ||
|
|
||
| repos: | ||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.16.1 | ||
| hooks: | ||
| - id: ruff | ||
| args: [--config, "lint.per-file-ignores={}"] | ||
| stages: [pre-push] | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: pytest | ||
| name: pytest | ||
| entry: uv run pytest | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true | ||
| stages: [pre-push] |
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.
Uh oh!
There was an error while loading. Please reload this page.