Skip to content

Commit

Permalink
Add pre-commit hook for ruff (#1990)
Browse files Browse the repository at this point in the history
* Add pre-commit hook for ruff

* Update lock file

* Scope Ruff format-on-save to python files only

* Disable format on save by default
  • Loading branch information
whabanks authored Nov 29, 2024
1 parent 9b682f1 commit 8ffc649
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
16 changes: 9 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
"vsliveshare.vsliveshare"
],
"settings": {
"ruff.lint.run": "onSave",
"ruff.configurationPreference": "filesystemFirst",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
"[python]": {
"ruff.lint.run": "onSave",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
},
"ruff.configurationPreference": "filesystemFirst"
}
}
},
Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/scripts/installations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ poetry completions zsh > ~/.zfunc/_poetry
cd /workspace
poetry install

# Install pre-commit hooks
poetry run pre-commit install

# Poe the Poet plugin tab completions
touch ~/.zfunc/_poe
poetry run poe _zsh_completion > ~/.zfunc/_poe
Expand Down
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
hooks:
# Run the linter
- id: ruff
args: [ --fix ]
# Run the formatter
- id: ruff-format
2 changes: 1 addition & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jinja2-cli = { version = "^0.8.2", extras = ["yaml"] }
mypy = "1.11.2"
monkeytype = "23.3.0"
poethepoet = "^0.24.4"
pre-commit = "^3.7.1"
ruff = "^0.6.9"

# stubs libraries to keep mypy happy
Expand Down

0 comments on commit 8ffc649

Please sign in to comment.