Skip to content

Commit 26788aa

Browse files
committed
chore: add ruff for linting and formatting
- Add ruff to dev dependencies - Configure ruff in pyproject.toml to match Google style - Add ruff linting to CI alongside pylint - Replace yapf with ruff format in CI - Remove yapf from dependencies - Add .git-blame-ignore-revs for formatting commit
1 parent 436f4c7 commit 26788aa

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

.git-blame-ignore-revs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# .git-blame-ignore-revs
2+
# Use this file to ignore commits in git blame that are just formatting changes
3+
# Configure with: git config blame.ignoreRevsFile .git-blame-ignore-revs
4+
5+
# Switch to ruff formatting
6+
# TODO: Add commit hash here after formatting commit

.github/workflows/ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
run: |
5353
source venv/bin/activate
5454
python3.10 -m pylint $(git ls-files '*.py')
55+
- name: Lint with ruff
56+
run: |
57+
source venv/bin/activate
58+
python3.10 -m ruff check .
5559
- name: Lint with mypy
5660
run: |
5761
source venv/bin/activate
@@ -96,7 +100,7 @@ jobs:
96100
source venv/bin/activate
97101
pip3 install --upgrade pip
98102
python3.10 -m pip install -e ".[dev]"
99-
- name: Check Formatting
103+
- name: Check Formatting with ruff
100104
run: |
101105
source venv/bin/activate
102-
yapf -d -r -p .
106+
python3.10 -m ruff format --check .

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,35 @@ ignore_patterns = [
2121
"build",
2222
"dist",
2323
]
24+
25+
[tool.ruff]
26+
target-version = "py310"
27+
line-length = 100
28+
indent-width = 4
29+
30+
[tool.ruff.lint]
31+
select = [
32+
"E", # pycodestyle errors
33+
"W", # pycodestyle warnings
34+
"F", # pyflakes
35+
"I", # isort
36+
"UP", # pyupgrade
37+
"B", # flake8-bugbear
38+
"C4", # flake8-comprehensions
39+
"PL", # pylint
40+
]
41+
ignore = [
42+
"PLR0913", # Too many arguments
43+
"PLR0912", # Too many branches
44+
"PLR0915", # Too many statements
45+
"PLR2004", # Magic value used in comparison
46+
"PLW0603", # Using the global statement
47+
"PLC0415", # Import outside toplevel
48+
"E501", # Line too long (handled by formatter)
49+
]
50+
51+
[tool.ruff.format]
52+
quote-style = "double"
53+
indent-style = "space"
54+
skip-magic-trailing-comma = false
55+
line-ending = "auto"

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
dev_requires = [
2828
'pytest>=7.1.2', 'setuptools>=63.4.2', 'pylint>=2.16.1',
2929
'pytest-cov>=3.0.0', 'mypy>=1.0.0', 'sphinx>=6.1.3',
30-
'sphinxcontrib-napoleon>=0.7', 'yapf>=0.32.0', 'toml>=0.10.2',
31-
'google-cloud-tasks>=2.13.1'
30+
'sphinxcontrib-napoleon>=0.7', 'toml>=0.10.2',
31+
'google-cloud-tasks>=2.13.1', 'ruff>=0.1.0'
3232
]
3333

3434
# Read in the package metadata per recommendations from:

0 commit comments

Comments
 (0)