Skip to content

Commit bea1bf5

Browse files
committed
[CI] Add ruff check and format
1 parent 1ec7b9b commit bea1bf5

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

.github/workflows/ruff.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Lint and format
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
check:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: astral-sh/ruff-action@v1
14+
with:
15+
args: check
16+
src: "."

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
*.DS_Store
1010

1111
riscv-target/
12+
# ignore ruff cache
13+
.ruff_cache

ruff.toml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Exclude a variety of commonly ignored directories.
2+
exclude = [
3+
".bzr",
4+
".direnv",
5+
".eggs",
6+
".git",
7+
".git-rewrite",
8+
".hg",
9+
".ipynb_checkpoints",
10+
".mypy_cache",
11+
".nox",
12+
".pants.d",
13+
".pyenv",
14+
".pytest_cache",
15+
".pytype",
16+
".ruff_cache",
17+
".svn",
18+
".tox",
19+
".venv",
20+
".vscode",
21+
"__pypackages__",
22+
"_build",
23+
"buck-out",
24+
"build",
25+
"dist",
26+
"node_modules",
27+
"site-packages",
28+
"venv",
29+
]
30+
31+
# Same as Black.
32+
line-length = 88
33+
indent-width = 4
34+
35+
# Assume Python 3.8
36+
target-version = "py38"
37+
38+
[lint]
39+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
40+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
41+
# McCabe complexity (`C901`) by default.
42+
select = ["E4", "E7", "E9", "F"]
43+
ignore = []
44+
45+
# Allow fix for all enabled rules (when `--fix`) is provided.
46+
fixable = ["ALL"]
47+
unfixable = ["F841"]
48+
49+
# Allow unused variables when underscore-prefixed.
50+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
51+
52+
[format]
53+
# Like Black, use double quotes for strings.
54+
quote-style = "double"
55+
56+
# Like Black, indent with spaces, rather than tabs.
57+
indent-style = "space"
58+
59+
# Like Black, respect magic trailing commas.
60+
skip-magic-trailing-comma = false
61+
62+
# Like Black, automatically detect the appropriate line ending.
63+
line-ending = "auto"
64+
65+
# Enable auto-formatting of code examples in docstrings. Markdown,
66+
# reStructuredText code/literal blocks and doctests are all supported.
67+
#
68+
# This is currently disabled by default, but it is planned for this
69+
# to be opt-out in the future.
70+
docstring-code-format = false
71+
72+
# Set the line length limit used when formatting code snippets in
73+
# docstrings.
74+
#
75+
# This only has an effect when the `docstring-code-format` setting is
76+
# enabled.
77+
docstring-code-line-length = "dynamic"

0 commit comments

Comments
 (0)