Skip to content

Commit 449cb12

Browse files
committed
Move to ruff for linting
1 parent ddce27f commit 449cb12

3 files changed

Lines changed: 46 additions & 15 deletions

File tree

.github/workflows/lint.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@ jobs:
1717
with:
1818
python_version: '3.11'
1919

20-
# Run flake8 and have it format the linting errors in the format of
21-
# the GitHub Workflow command to register error annotations. This
22-
# means that our flake8 output is automatically added as an error
23-
# annotation to both the run result and in the "Files" tab of a
24-
# pull request.
25-
#
26-
# Format used:
27-
# ::error file={filename},line={line},col={col}::{message}
28-
- name: Run flake8
29-
run: "flake8 \
30-
--format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s'"
20+
- name: Run pre-commit hooks
21+
run: SKIP=ruff pre-commit run --all-files
22+
23+
# Run `ruff` using github formatting to enable automatic inline annotations.
24+
- name: Run ruff
25+
run: "ruff check --format=github ."

.pre-commit-config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: check-merge-conflict
6+
- id: check-toml
7+
- id: check-yaml
8+
- id: end-of-file-fixer
9+
- id: trailing-whitespace
10+
args: [--markdown-linebreak-ext=md]
11+
12+
- repo: local
13+
hooks:
14+
- id: ruff
15+
name: ruff
16+
description: Run ruff linting
17+
entry: poetry run ruff check --force-exclude
18+
language: system
19+
'types_or': [python, pyi]
20+
require_serial: true
21+
args: [--fix, --exit-non-zero-on-fix]

pyproject.toml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,29 @@ python-dotenv = "1.0.0"
3030
loguru = "0.7.2"
3131

3232
[tool.poetry.dev-dependencies]
33-
flake8 = "^3.9.0"
34-
flake8-annotations = "^2.6.2"
35-
flake8-docstrings = "^1.6.0"
36-
flake8-import-order = "^0.18.1"
33+
pre-commit = "3.4.0"
34+
ruff = "0.0.288"
3735

3836
[tool.poetry.scripts]
3937
olli = "olli.__main__:start"
4038

39+
[tool.ruff]
40+
target-version = "py311"
41+
extend-exclude = [".cache"]
42+
ignore = [
43+
"ANN002", "ANN003", "ANN101", "ANN102",
44+
"ARG003",
45+
"C901",
46+
"D100", "D104", "D105", "D107", "D203", "D212", "D214", "D215", "D416",
47+
]
48+
line-length = 120
49+
select = ["ALL"]
50+
51+
[tool.ruff.isort]
52+
order-by-type = false
53+
case-sensitive = true
54+
combine-as-imports = true
55+
4156
[build-system]
4257
requires = ["poetry-core>=1.0.0"]
4358
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)