Skip to content

Commit

Permalink
Add ruff unused import check to pre-commit and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
hnryjmes committed Jun 21, 2024
1 parent de7adcb commit 6ee7984
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
16 changes: 12 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ jobs:
name: Set Environment File
command: cp local.env .env

- run: pipenv install pre-commit

# Download and cache dependencies
# ensure this step occurs *before* installing dependencies
- restore_cache:
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum ".pre-commit-config.yaml" }}

- run:
name: Install Dependencies
Expand All @@ -43,10 +45,16 @@ jobs:
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
- run:
name: Ruff
command: pipenv run pre-commit run ruff --from-ref origin/HEAD --to-ref HEAD

- save_cache:
paths:
- ./venv
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- ./.venv
- ~/.cache/pre-commit
# the cache key changes whenever any of the branch name, Pipfile.lock checksum, or .pre-commit-config.yaml checksum change
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum ".pre-commit-config.yaml" }}

- run:
name: Check migrations are made
Expand All @@ -60,7 +68,7 @@ jobs:
- run:
name: Upload code coverage
command: ./codecov

tests_postgres13:
docker:
- image: cimg/python:3.8.17
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
exclude: (exporter/assets/built/|caseworker/assets/built/)
repos:
# ruff-pre-commit docs recommend running ruff before black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
hooks:
# Config for ruff lives in pyproject.toml
- id: ruff
args: [ --fix ]
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[tool.black]
line-length = 120
target-version = ['py36', 'py37', 'py38']
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
/(
Expand All @@ -27,3 +27,6 @@ exclude = '''
[tool.isort]
profile = 'black'
line_length = 120 # To match Black's line-length above.

[tool.ruff.lint]
select = ["F401"]

0 comments on commit 6ee7984

Please sign in to comment.