Skip to content

Run ruff and yapf in pre-commit #481

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: ./check-license.sh
PreCommit:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: pipx run pre-commit run --all-files
Envvars:
runs-on: ubuntu-22.04
outputs:
Expand All @@ -43,16 +48,12 @@ jobs:
strategy:
matrix:
python-version: ${{ fromJSON(needs.Envvars.outputs.version_matrix) }}
task: [Typecheck, Lint, Ruff, Yapf, Test]
task: [Typecheck, Lint, Test]
include:
- task: Typecheck
cmd: pytype -j auto .
- task: Lint
cmd: pylint --rcfile .pylintrc --recursive yes .
- task: Ruff
cmd: ruff check
- task: Yapf
cmd: yapf . -drp
- task: Test
cmd: pytest
steps:
Expand Down
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Learn more about this config here: https://pre-commit.com

# To enable these pre-commit hooks:
# 1. Install pre-commit: `pip install pre-commit`
# or if you are using pipx: `pipx install pre-commit`
# or if you are using uv: `uv tool install pre-commit`.
# Then in the project root directory run `pre-commit install`

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.2
hooks:
- id: ruff

- repo: https://github.com/google/yapf
rev: v0.43.0
hooks:
- id: yapf
args: [--in-place, --recursive, --parallel]