Skip to content

Commit

Permalink
Add ruff to pre-commit hooks, create pyproject.toml file for configur…
Browse files Browse the repository at this point in the history
…ate black and ruff linters
  • Loading branch information
Maksymilian-Plywaczyk committed Nov 23, 2023
1 parent a765969 commit f01485f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
15 changes: 13 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
files: 'api/'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude: requirements.txt
- id: check-yaml
- id: check-added-large-files

- id: detect-private-key
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
Expand All @@ -17,3 +19,12 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo:
https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.1.2
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[tool.black]
line-length = 88
include = '\.pyi?$'
skip-string-normalization = true
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
ignore = []

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
"alembic/*"
]

# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"

0 comments on commit f01485f

Please sign in to comment.