Skip to content

Commit 7bdaca3

Browse files
committed
feat: add ruff linter with ci check
Liniting the python files in tests directory would reduce whitespace etc change and enforce basic coding standard for those. Kind of opportunistic PR as there might be other opinions about how to deal with this.
1 parent 6520331 commit 7bdaca3

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
2828
readarray -t changed_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
2929
~/go/bin/editorconfig-checker ${changed_files[@]}
30+
- name: Lint and format Python with Ruff
31+
uses: astral-sh/ruff-action@v1
3032

3133
typo:
3234
runs-on: ubuntu-latest

tests/pyproject.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,66 @@ testpaths = ["."]
2121
[build-system]
2222
requires = ["poetry-core"]
2323
build-backend = "poetry.core.masonry.api"
24+
25+
[tool.ruff]
26+
# Exclude a variety of commonly ignored directories.
27+
exclude = [
28+
".bzr",
29+
".direnv",
30+
".eggs",
31+
".git",
32+
".git-rewrite",
33+
".hg",
34+
".ipynb_checkpoints",
35+
".mypy_cache",
36+
".nox",
37+
".pants.d",
38+
".pyenv",
39+
".pytest_cache",
40+
".pytype",
41+
".ruff_cache",
42+
".svn",
43+
".tox",
44+
".venv",
45+
".vscode",
46+
"__pypackages__",
47+
"_build",
48+
"buck-out",
49+
"build",
50+
"dist",
51+
"node_modules",
52+
"site-packages",
53+
"venv",
54+
]
55+
56+
# Same as Black.
57+
line-length = 88
58+
indent-width = 4
59+
60+
# Assume Python 3.9
61+
target-version = "py39"
62+
63+
[tool.ruff.lint]
64+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
65+
select = ["E4", "E7", "E9", "F"]
66+
ignore = []
67+
68+
# Allow fix for all enabled rules (when `--fix`) is provided.
69+
fixable = ["ALL"]
70+
unfixable = []
71+
72+
# Allow unused variables when underscore-prefixed.
73+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
74+
75+
[tool.ruff.format]
76+
# Like Black, use double quotes for strings.
77+
quote-style = "double"
78+
79+
# Like Black, indent with spaces, rather than tabs.
80+
indent-style = "space"
81+
82+
# Like Black, respect magic trailing commas.
83+
skip-magic-trailing-comma = false
84+
85+
# Like Black, automatically detect the appropriate line ending.
86+
line-ending = "auto"

0 commit comments

Comments
 (0)