Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff unused import check to pre-commit and CI #258

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- run:
name: Upload code coverage
command: ./codecov

tests_postgres13:
docker:
- image: cimg/python:3.8.17
Expand Down Expand Up @@ -127,18 +127,15 @@ jobs:
steps:
- checkout

- run: pipenv install pre-commit

- restore_cache:
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}-{{ checksum ".pre-commit-config.yaml" }}

- run:
name: Install Dependencies
command: pipenv sync --dev

- save_cache:
paths:
- ./venv
key: dependencies-{{ .Branch }}-{{ checksum "Pipfile.lock" }}

- run:
name: Prospector
command: pipenv run prospector -W pylint -W pep257
Expand All @@ -156,6 +153,18 @@ jobs:
command: |
pipenv run bandit -c bandit.yaml -r .

- run:
name: Ruff
command: pipenv run pre-commit run ruff --from-ref origin/HEAD --to-ref HEAD

- save_cache:
paths:
- ./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" }}


workflows:
version: 2
test:
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"]