Skip to content

Commit 05b567c

Browse files
authored
[Lint] Migrate from flake8/isort to ruff for faster linting (#613)
* [Lint] Migrate from flake8/isort to ruff for faster linting - Replace flake8 and isort with ruff in pre-commit configuration - Configure comprehensive ruff rule set including pycodestyle, Pyflakes, pyupgrade, flake8-bugbear, flake8-simplify, isort, flake8-comprehensions, flake8-type-checking, and flake8-commas - Enable automatic fixing with --fix and --unsafe-fixes flags - Update pre-commit-hooks to v6.0.0 and tj-actions/changed-files to v47.0.0 - Configure per-file ignores for __init__.py and evals/harness.py - Set line length to 127 characters and target Python 3.10+ This change significantly improves linting performance while maintaining code quality standards. * add debugger * fix ruff rules * update
1 parent b5d48b7 commit 05b567c

File tree

4 files changed

+44
-17
lines changed

4 files changed

+44
-17
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ jobs:
2727
pre-commit install-hooks
2828
- name: Get changed files
2929
id: changed-files
30-
uses: tj-actions/changed-files@v46.0.5
30+
uses: tj-actions/changed-files@v47.0.0
3131
- name: Lint modified files
3232
run: pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}

.github/workflows/reusable-ci-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
- name: Get changed files
191191
if: steps.check_skip.outputs.skip_tests == 'false'
192192
id: changed-files
193-
uses: tj-actions/changed-files@v46.0.5
193+
uses: tj-actions/changed-files@v47.0.0
194194

195195
# =================================================================
196196
# STAGE 2: OPS TESTS
@@ -301,7 +301,7 @@ jobs:
301301
- name: Get changed files
302302
if: steps.check_skip.outputs.skip_tests == 'false'
303303
id: changed-files
304-
uses: tj-actions/changed-files@v46.0.5
304+
uses: tj-actions/changed-files@v47.0.0
305305

306306
- name: Install/Update Dependencies
307307
if: steps.check_skip.outputs.skip_tests == 'false'

.pre-commit-config.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v5.0.0
3+
rev: v6.0.0
44
hooks:
55
- id: check-symlinks
66
- id: trailing-whitespace
77
args: [--markdown-linebreak-ext=md]
88
- id: end-of-file-fixer
99
- id: check-yaml
1010
- id: check-toml
11-
- id: check-ast
1211
- id: check-added-large-files
1312
- id: check-merge-conflict
1413
- id: detect-private-key
15-
- id: debug-statements
16-
- repo: https://github.com/pycqa/isort
17-
rev: 5.12.0
14+
- repo: https://github.com/astral-sh/ruff-pre-commit
15+
rev: v0.14.0
1816
hooks:
19-
- id: isort
20-
- repo: https://github.com/PyCQA/flake8
21-
rev: 7.0.0
22-
hooks:
23-
- id: flake8
24-
args: [--max-line-length=127]
17+
- id: ruff-check
18+
args: [--fix, --exit-non-zero-on-fix]

pyproject.toml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,46 @@ Repository = "https://github.com/fla-org/flash-linear-attention"
3333
[build-system]
3434
requires = ["setuptools>=45", "wheel"]
3535

36-
[tool.isort]
37-
line_length = 127
38-
multi_line_output = 3
36+
[tool.ruff.lint.isort]
37+
known-first-party = ["fla"]
38+
force-sort-within-sections = false
3939

4040
[tool.pytest.ini_options]
4141
log_cli = true
4242
log_cli_level = "INFO"
4343
pythonpath = [
4444
"."
4545
]
46+
47+
[tool.ruff]
48+
target-version = "py310"
49+
line-length = 127
50+
51+
[tool.ruff.format]
52+
docstring-code-format = true
53+
54+
[tool.ruff.lint]
55+
select = [
56+
"E", # pycodestyle
57+
"F", # Pyflakes
58+
"UP", # pyupgrade
59+
"B", # flake8-bugbear
60+
"SIM", # flake8-simplify
61+
"I", # isort
62+
"C4", # flake8-comprehensions
63+
"TCH", # flake8-type-checking
64+
"COM", # flake8-commas
65+
"T", # flake8-debugger
66+
]
67+
ignore = [
68+
"E501",
69+
"E741",
70+
"B023",
71+
"B008",
72+
"SIM108",
73+
]
74+
75+
[tool.ruff.lint.per-file-ignores]
76+
"__init__.py" = ["F401"]
77+
"fla/utils.py" = ["TCH004"]
78+
"evals/harness.py" = ["I", "TCH"]

0 commit comments

Comments
 (0)