Skip to content

Commit 8186a1e

Browse files
committed
Replace flake8 and black with ruff
1 parent 9d6c8c2 commit 8186a1e

File tree

4 files changed

+77
-147
lines changed

4 files changed

+77
-147
lines changed

Diff for: .github/workflows/format.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
pull_request:
99

1010
jobs:
11-
black-format-check:
11+
format-check:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout Code

Diff for: Makefile

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
VENV := .venv
22

3-
# Format Python code with black
3+
# Format Python code with ruff format
44
.PHONY: format
55
format:
6-
@echo "Formatting Python files with black..."
7-
$(VENV)/bin/black .
6+
@echo "Formatting Python files with ruff format..."
7+
$(VENV)/bin/ruff format
88

9-
# Run flake8 to lint Python code in the whole repository
9+
# Run ruff check to lint Python code in the whole repository
1010
.PHONY: lint
1111
lint:
12-
@echo "Linting Python files with flake8..."
13-
# stop if there are Python syntax errors or undefined names
14-
$(VENV)/bin/flake8 ./inference_perf --count --select=E9,F63,F7,F82 --show-source --statistics
15-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
16-
$(VENV)/bin/flake8 ./inference_perf --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
12+
@echo "Linting Python files with ruff check..."
13+
$(VENV)/bin/ruff check
1714

1815
# Perform type checking
1916
.PHONY: type-check
@@ -30,7 +27,7 @@ all-deps:
3027
fi
3128
@echo "Activating virtual environment and installing dependencies..."
3229
$(VENV)/bin/pip install --upgrade pip
33-
$(VENV)/bin/pip install -r requirements.txt
30+
$(VENV)/bin/pip install -e .
3431

3532
.PHONY: check
36-
check: all-deps lint type-check
33+
check: all-deps lint type-check

Diff for: pdm.lock

+23-133
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pyproject.toml

+45-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,50 @@ distribution = true
1616

1717
[dependency-groups]
1818
dev = [
19-
"flake8>=7.1.1",
20-
"black>=25.1.0",
2119
"mypy>=1.14.1",
20+
"ruff>=0.9.4",
2221
]
22+
23+
[tool.ruff]
24+
# The GitHub editor is 127 chars wide
25+
line-length = 127
26+
indent-width = 4
27+
28+
[tool.ruff.lint]
29+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
30+
# On top of the defaults (`E4`, E7`, `E9`, and `F`), enable flake8-bugbear (`B`)
31+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
32+
# McCabe complexity (`C901`) by default.
33+
select = ["E4", "E7", "E9", "F", "B"]
34+
ignore = []
35+
36+
# Allow fix for all enabled rules (when `--fix`) is provided.
37+
fixable = ["ALL"]
38+
unfixable = []
39+
40+
[tool.ruff.format]
41+
# Like Black, use double quotes for strings.
42+
quote-style = "double"
43+
44+
# Like Black, indent with spaces, rather than tabs.
45+
indent-style = "space"
46+
47+
# Like Black, respect magic trailing commas.
48+
skip-magic-trailing-comma = false
49+
50+
# Like Black, automatically detect the appropriate line ending.
51+
line-ending = "auto"
52+
53+
# Enable auto-formatting of code examples in docstrings. Markdown,
54+
# reStructuredText code/literal blocks and doctests are all supported.
55+
#
56+
# This is currently disabled by default, but it is planned for this
57+
# to be opt-out in the future.
58+
docstring-code-format = false
59+
60+
# Set the line length limit used when formatting code snippets in
61+
# docstrings.
62+
#
63+
# This only has an effect when the `docstring-code-format` setting is
64+
# enabled.
65+
docstring-code-line-length = "dynamic"

0 commit comments

Comments
 (0)