Skip to content

Commit bbbf0cf

Browse files
committed
Introduce the Ruff linter and formatter
Ruff is a modern linter and formatter in one.
1 parent d039dcf commit bbbf0cf

2 files changed

Lines changed: 82 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
python -m pip install .
30+
python -m pip install ruff
31+
- name: Lint
32+
run: python -m ruff lint .
3033
- name: Test with python unittest
3134
run: python -m unittest

pyproject.toml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,82 @@ include = ["trsfile", "trsfile.*"]
5151
[tool.setuptools_scm]
5252
# This writes the computed version into the package at build time
5353
write_to = "trsfile/VERSION.txt"
54+
55+
[tool.ruff]
56+
# Exclude a variety of commonly ignored directories.
57+
exclude = [
58+
".bzr",
59+
".direnv",
60+
".eggs",
61+
".git",
62+
".git-rewrite",
63+
".hg",
64+
".ipynb_checkpoints",
65+
".mypy_cache",
66+
".nox",
67+
".pants.d",
68+
".pyenv",
69+
".pytest_cache",
70+
".pytype",
71+
".ruff_cache",
72+
".svn",
73+
".tox",
74+
".venv",
75+
".vscode",
76+
"__pypackages__",
77+
"_build",
78+
"buck-out",
79+
"build",
80+
"dist",
81+
"node_modules",
82+
"site-packages",
83+
"venv",
84+
]
85+
86+
# Same as Black.
87+
line-length = 88
88+
indent-width = 4
89+
90+
# Assume Python 3.10
91+
target-version = "py310"
92+
93+
[tool.ruff.lint]
94+
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
95+
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
96+
# McCabe complexity (`C901`) by default.
97+
select = ["E4", "E7", "E9", "F"]
98+
ignore = []
99+
100+
# Allow fix for all enabled rules (when `--fix`) is provided.
101+
fixable = ["ALL"]
102+
unfixable = []
103+
104+
# Allow unused variables when underscore-prefixed.
105+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
106+
107+
[tool.ruff.format]
108+
# Like Black, use double quotes for strings.
109+
quote-style = "double"
110+
111+
# Like Black, indent with spaces, rather than tabs.
112+
indent-style = "space"
113+
114+
# Like Black, respect magic trailing commas.
115+
skip-magic-trailing-comma = false
116+
117+
# Like Black, automatically detect the appropriate line ending.
118+
line-ending = "auto"
119+
120+
# Enable auto-formatting of code examples in docstrings. Markdown,
121+
# reStructuredText code/literal blocks and doctests are all supported.
122+
#
123+
# This is currently disabled by default, but it is planned for this
124+
# to be opt-out in the future.
125+
docstring-code-format = false
126+
127+
# Set the line length limit used when formatting code snippets in
128+
# docstrings.
129+
#
130+
# This only has an effect when the `docstring-code-format` setting is
131+
# enabled.
132+
docstring-code-line-length = "dynamic"

0 commit comments

Comments
 (0)