Skip to content

Commit

Permalink
Merge pull request #1 from AlessandroMiola/ruff_config
Browse files Browse the repository at this point in the history
feat: add tooling (ruff, pre-commit)
  • Loading branch information
AlessandroMiola authored Mar 25, 2024
2 parents b8f557c + ed7e922 commit ffca697
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
*.pyc
.vscode/
.pytest_cache/
.ruff_cache
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
default_language_version:
python: python3.10

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- repo: local
hooks:
- id: ruff lint
name: ruff (linter)
entry: just ruff-fix
language: system
types: [python]
- id: ruff format
name: ruff (formatter)
entry: just ruff-format
language: system
types: [python]
41 changes: 41 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Use PowerShell instead of sh
# set shell := ["powershell.exe", "-c"]

help:
@just --list

install:
@echo "🚀 Installing dependencies"
@poetry install --with dev

install-pre-commit:
@echo "🚀 Setting up the hooks"
@poetry run pre-commit install

check-project:
@echo "🚀 Checking consistency between poetry.lock and pyproject.toml"
@poetry check --lock
@echo "🚀 Running the hooks against all files"
@poetry run pre-commit run --all-files

ruff:
@echo "🚀 Linting the project with Ruff"
@poetry run ruff check .

ruff-show-violations:
@echo "🚀 Linting the project with Ruff and show violations"
@poetry run ruff check --output-format="grouped" .

ruff-fix:
@echo "🚀 Linting the project with Ruff and autofix violations (where possible)"
@poetry run ruff check --fix .

ruff-format:
@echo "🚀 Formatting the code with Ruff"
@poetry run ruff format .

ruff-format-check:
@echo "🚀 Listing files Black would reformat"
@poetry run ruff format --check .

lint-and-format: ruff-fix ruff-format
196 changes: 195 additions & 1 deletion poetry.lock

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

Loading

0 comments on commit ffca697

Please sign in to comment.