Skip to content
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

Switch to ruff for lint and format #1559

Merged
merged 5 commits into from
Sep 22, 2024
Merged
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
14 changes: 0 additions & 14 deletions .flake8

This file was deleted.

31 changes: 13 additions & 18 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,24 @@ on:
permissions: { }

jobs:
build:
lint:
name: Lint Code Base
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
statuses: write

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Ruff check
uses: chartboost/ruff-action@v1
with:
fetch-depth: 0
version: 0.6.7
args: "check"
changed-files: "true"

- name: Lint Code Base
uses: super-linter/super-linter/slim@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_PYTHON_BLACK: true
VALIDATE_PYTHON_FLAKE8: true
VALIDATE_PYTHON_ISORT: true
LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: "pyproject.toml"
PYTHON_FLAKE8_CONFIG_FILE: ".flake8"
PYTHON_ISORT_CONFIG_FILE: "pyproject.toml"
- name: Ruff format
uses: chartboost/ruff-action@v1
with:
version: 0.6.7
args: "format"
changed-files: "true"
22 changes: 5 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,9 @@ repos:
- id: check-yaml
- id: check-toml

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.7
hooks:
- id: isort
additional_dependencies: ["isort[pyproject]"]

- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: ["--config=pyproject.toml"]

- repo: https://github.com/PyCQA/flake8
rev: 7.1.0
hooks:
- id: flake8
args: ["--config=.flake8"]
additional_dependencies: [flake8-isort]
- id: ruff
args: [ --fix ]
- id: ruff-format
2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"boto3typed.boto3-ide",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-python.isort"
"charliermarsh.ruff"
]
}
11 changes: 4 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"editor.formatOnSave": false
},
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.formatOnSave": true
"editor.defaultFormatter": "charliermarsh.ruff"
},
"files.associations": {
"*.envrc": "shellscript",
Expand All @@ -19,10 +21,5 @@
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"githubPullRequests.ignoredPullRequestBranches": ["develop", "staging"],
"python.formatting.blackPath": "${workspaceFolder}/.venv/bin/black",
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"python.linting.flake8Args": ["--config=.flake8"],
"python.linting.flake8Path": "${workspaceFolder}/.venv/bin/flake8",
"isort.args": ["--profile", "black"]
"python.languageServer": "Pylance"
}
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,17 @@ reset_db:
docker compose exec backend bash -c "python manage.py reset_db --noinput"
docker compose exec backend bash -c "python manage.py migrate"

ruff-all:
ruff check .

ruff:
ruff check --fix $(shell git diff --name-only --staged | grep -E '\.py$$|\/pyproject.toml$$')

ruff-all-docker:
docker exec care bash -c "ruff check ."

ruff-docker:
docker exec care bash -c "ruff check --fix $(shell git diff --name-only --staged | grep -E '\.py$$|\/pyproject.toml$$')"

%:
docker compose exec backend bash -c "python manage.py $*"
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ requests-mock = "==1.12.1"
tblib = "==3.0.0"
watchdog = "==5.0.2"
werkzeug = "==3.0.4"
ruff = "==0.6.7"

[docs]
furo = "==2024.8.6"
Expand Down
63 changes: 44 additions & 19 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading