Skip to content

Commit

Permalink
feat: Use ruff for linting (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
eirsyl committed Jun 27, 2024
1 parent 317f721 commit 25f4a56
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 139 deletions.
2 changes: 0 additions & 2 deletions .flake8

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
strategy:
fail-fast: false
matrix:
check: [isort, mypy, black, flake8]
check: [isort, mypy, black, ruff-check, ruff-format]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Read .tool-versions
uses: marocchino/tool-versions-action@v1
id: versions
Expand Down
74 changes: 37 additions & 37 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
---
default_install_hook_types: [pre-commit, commit-msg]
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: "v9.11.0"
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]
args:
- "--config=commitlint.config.js"
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: "v9.11.0"
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]
args:
- "--config=commitlint.config.js"

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: 'v0.38.0'
hooks:
- id: markdownlint
args:
- '--config=.markdownlint.yaml'
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: "v0.38.0"
hooks:
- id: markdownlint
args:
- "--config=.markdownlint.yaml"

- repo: local
hooks:
- id: isort
name: black
entry: .venv/bin/isort
language: system
types: [python]
- id: black
name: black
entry: .venv/bin/black
language: system
types: [python]
- id: flake8
name: black
entry: .venv/bin/flake8
language: system
types: [python]
- id: mypy
name: mypy
entry: .venv/bin/mypy
language: system
types: [python]
require_serial: true
- repo: local
hooks:
- id: isort
name: isort
entry: .venv/bin/isort
language: system
types: [python]
- id: black
name: black
entry: .venv/bin/black
language: system
types: [python]
- id: ruff
name: ruff
entry: .venv/bin/ruff
language: system
types: [python]
- id: mypy
name: mypy
entry: .venv/bin/mypy
language: system
types: [python]
require_serial: true
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $(POETRY): ; $(info $(M) checking POETRY...)
@touch $@

.PHONY: lint
lint: .venv lint-isort lint-black lint-flake8 lint-mypy ## Run all linters
lint: .venv lint-isort lint-black lint-ruff-check lint-ruff-format lint-mypy ## Run all linters

.PHONY: lint-isort
lint-isort: .venv ; $(info $(M) running isort...) @ ## Run isort linter
Expand All @@ -28,18 +28,21 @@ lint-black: .venv ; $(info $(M) running black...) @ ## Run black linter
$Q $(POETRY) run black --check $(PACKAGE)
$Q $(POETRY) run black --check $(TESTS)

.PHONY: lint-flake8
lint-flake8: .venv ; $(info $(M) running flake8...) @ ## Run flake8 linter
$Q $(POETRY) run flake8 $(PACKAGE)
$Q $(POETRY) run flake8 $(TESTS)

.PHONY: lint-mypy
lint-mypy: .venv ; $(info $(M) running mypy...) @ ## Run mypy linter
$Q $(POETRY) run mypy $(PACKAGE)
$Q $(POETRY) run mypy $(TESTS)

.PHONY: lint-ruff-check
lint-ruff-check: .venv | $(BASE) ; $(info $(M) running ruff check…) @ ## Run ruff check linter
$Q $(POETRY) run ruff check $(PACKAGE)

.PHONY: lint-ruff-format
lint-ruff-format: .venv | $(BASE) ; $(info $(M) running ruff format…) @ ## Run ruff format linter
$Q $(POETRY) run ruff format $(PACKAGE) --check

.PHONY: fix
fix: .venv fix-isort fix-black ## Run all fixers
fix: .venv fix-isort fix-black fix-ruff-check fix-ruff-format ## Run all fixers

.PHONY: fix-isort
fix-isort: .venv ; $(info $(M) running isort...) @ ## Run isort fixer
Expand All @@ -51,6 +54,14 @@ fix-black: .venv ; $(info $(M) running black...) @ ## Run black fixer
$Q $(POETRY) run black $(PACKAGE)
$Q $(POETRY) run black $(TESTS)

.PHONY: fix-ruff-check
fix-ruff-check: .venv | $(BASE) ; $(info $(M) running ruff check…) @ ## Run ruff check fixer
$Q $(POETRY) run ruff check $(PACKAGE) --fix

.PHONY: fix-ruff-format
fix-ruff-format: .venv | $(BASE) ; $(info $(M) running ruff format…) @ ## Run ruff format fixer
$Q $(POETRY) run ruff format $(PACKAGE)

.PHONY: test
test: .venv ; $(info $(M) running tests...) @ ## Run tests
$Q $(POETRY) run pytest --cov-report $(TEST_COV_REP) --cov $(PACKAGE) --codeblocks -v
Expand Down
106 changes: 31 additions & 75 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 25f4a56

Please sign in to comment.