Skip to content

Commit 7d37afc

Browse files
committed
Add GitHub Action for Ruff (code formatting check)
Calls Action actions/checkout@v4
1 parent 87e63ee commit 7d37afc

3 files changed

Lines changed: 28 additions & 36 deletions

File tree

.github/workflows/ruff.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Ruff
3+
on: [ pull_request ]
4+
5+
permissions:
6+
contents: read
7+
pull-requests: write # Required for posting comments
8+
9+
jobs:
10+
ruff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
# Check for formatting errors (but don't fix them)
15+
16+
- uses: astral-sh/ruff-action@v3
17+
with:
18+
github-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
19+
args: "check"

.ruff.toml

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,12 @@ target-version = "py312"
33

44
# Max line length (matches Black's default)
55
line-length = 88
6+
indent-width = 4
67

7-
# Exclude a variety of commonly ignored directories.
8-
exclude = [
9-
".direnv",
10-
".eggs",
11-
".git",
12-
".mypy_cache",
13-
".nox",
14-
".pants.d",
15-
".pyenv",
16-
".pytest_cache",
17-
".pytype",
18-
".ruff_cache",
19-
".svn",
20-
".tox",
21-
".venv",
22-
".vscode",
23-
"__pypackages__",
24-
"_build",
25-
"build",
8+
# Amend exclude list in addtion to "exclude".
9+
# See https://docs.astral.sh/ruff/configuration/
10+
extend-exclude = [
2611
"contrib",
27-
"dist",
28-
"site-packages",
29-
"venv",
3012
]
3113

3214

@@ -44,7 +26,6 @@ select = [
4426
"C90", # mccabe complexity
4527
"B", # flake8-bugbear
4628
"A", # flake8-builtins
47-
"COM", # flake8-commas
4829
"RUF", # Ruff-specific rules
4930
]
5031

@@ -54,8 +35,7 @@ ignore = [
5435
"D107", # Missing docstring in __init__
5536
"D203", # Conflicts with D211 (one blank line before class docstring)
5637
"D213", # Conflicts with D212 (multi-line docstring start convention)
57-
# "D401", # First line of docstring should be in imperative mood
58-
"COM812", #
38+
"E501", # Line too long (Let the formatter handle this)
5939
]
6040

6141
# Allow autofix for everything except complexity and annotations
@@ -85,17 +65,9 @@ quote-style = "double"
8565
"D301" # Use `r"""` if any backslashes in a docstring
8666
]
8767
"tests/**/test_*.py" = [
88-
"ANN001", # Missing type annotation for function argument
89-
"ANN002", # Missing type annotation for variable
90-
"ANN003", # Missing type annotation for class attribute
91-
"ANN201", # Missing return type annotation
92-
"ANN202", # Missing return type annotation for private function
93-
"ANN204", # Missing return type annotation for special method `__init__`
94-
"ANN401", # Missing type annotation for self in method
95-
"D100", # Missing docstring in public module
96-
"D101", # Missing docstring in public class
97-
"D103", # Missing docstring in public function
98-
"D105", # Missing docstring in magic method
68+
"ANN", # Ignore ALL annotations in tests (simpler than listing specific codes)
69+
"D", # Ignore ALL docstrings in tests
70+
"S101", # (Optional) If you add flake8-bandit, this allows "assert" in tests
9971
]
10072
# Ignore unused imports in all __init__.py files
10173
"__init__.py" = ["F401"]

changelog.d/127.infra.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a new GitHub Action for code formatting issues using Ruff.

0 commit comments

Comments
 (0)