Skip to content

Commit

Permalink
Merge pull request #258 from uktrade/add_ruff_unused_import_check_202…
Browse files Browse the repository at this point in the history
…40621

Add ruff unused import check to pre-commit and CI
  • Loading branch information
hnryjmes authored Jun 21, 2024
2 parents de7adcb + 8706c8a commit e17e70c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
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"]

0 comments on commit e17e70c

Please sign in to comment.