diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 18efc80..21bdc03 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -35,6 +35,12 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python_version }} + cache: pip + + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - name: Install dependencies run: | @@ -42,7 +48,7 @@ jobs: - name: style & lint checks run: | - pre-commit run --all-files + pre-commit run --all-files --color=always - name: pytest and coverage run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dba4f25..eb69216 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ repos: - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.9.1 hooks: - id: black language_version: python3 # temp exlude osrm: black fails to reformat for some reason args: [routingpy, tests, --exclude, routingpy/routers/mapbox_osrm.py] -- repo: https://github.com/pycqa/flake8 - rev: 5.0.4 # pick a git hash / tag to point to +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.290 hooks: - - id: flake8 + - id: ruff - repo: https://github.com/pycqa/isort - rev: 5.11.5 + rev: 5.12.0 hooks: - id: isort name: isort (python) diff --git a/pyproject.toml b/pyproject.toml index 9c68166..e11e9c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,3 +66,44 @@ skip = [ "build", "dist", ] + +[tool.ruff] +# Enable the pycodestyle (`E`) and Pyflakes (`F`) rules by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E", "F"] +ignore = ["E203", "E266", "E501", "F403", "E722", "F405"] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", + "__pycache__", + "docs", + "examples", +] +per-file-ignores = {} + +line-length = 105 + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"