-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from RoBorregos/main
precommit to branch
- Loading branch information
Showing
12 changed files
with
219 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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,14 @@ | ||
name: pre-commit | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: ["**"] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v3 | ||
- uses: pre-commit/[email protected] |
This file contains 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,12 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
# Ruff version. | ||
rev: v0.8.4 | ||
hooks: | ||
# Run the linter. | ||
- id: ruff | ||
types_or: [python, pyi] | ||
# args: [--fix] | ||
# Run the formatter. | ||
- id: ruff-format | ||
types_or: [python, pyi] |
This file contains 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,55 @@ | ||
# Project setup | ||
|
||
## Pre-commit | ||
|
||
[Pre-commit](https://pre-commit.com/) is a framework for managing and maintaining multi-language pre-commit hooks. It is a useful tool to ensure that code is formatted and linted before committing. The following hooks are used in this project: | ||
|
||
- [ruff](https://github.com/astral-sh/ruff-pre-commit/tree/main) (linter and formatter for python) | ||
|
||
To install pre-commit and the repo's hooks, run the following commands: | ||
|
||
```bash | ||
pip install pre-commit | ||
pre-commit install | ||
``` | ||
|
||
To run against all files (useful when adding new hooks), use: | ||
|
||
```bash | ||
pre-commit run --all-files | ||
``` | ||
|
||
## Ruff | ||
|
||
Ruff is a linter and formatter for python. It is used to mantain consistency and readability in the codebase. Ruff in installed as a pre-commit hook, but can also be run manually. To install ruff, run the following command: | ||
|
||
```bash | ||
pip install ruff | ||
``` | ||
|
||
To run ruff, use the following command: | ||
|
||
```bash | ||
ruff check | ||
``` | ||
|
||
### Vscode integration | ||
|
||
If you are using vscode, you can add the following in `.vscode/settings.json` to enable ruff formatting on save. For this to work, you must also install the [Ruff extension for vscode](https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff). | ||
|
||
```json | ||
{ | ||
"[python]": { | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.organizeImports": "explicit" | ||
}, | ||
"editor.defaultFormatter": "charliermarsh.ruff" | ||
} | ||
} | ||
``` | ||
|
||
### Other integrations | ||
|
||
For integration with other editors, check the [ruff documentation](https://docs.astral.sh/ruff/editors/setup/) |
This file contains 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 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 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 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.