Skip to content

Commit 4f974ad

Browse files
authored
Adding unified linting/formatting using Ruff (#54)
* Adding unified linting/formatting using Ruff. * Continue on error for now until I run it on the entire codebase (to prevent merge conflicts in the recent PR).
1 parent e7a4bad commit 4f974ad

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

.github/workflows/lint-format.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Ruff
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ruff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.12"
19+
20+
- name: Install Ruff
21+
run: pip install ruff>=0.8.4
22+
23+
- name: Run Ruff linter
24+
run: ruff check .
25+
continue-on-error: true
26+
27+
- name: Run Ruff formatter check
28+
run: ruff format --check .
29+
continue-on-error: true

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,43 @@ These are the list of HTTP endpoints that can be called:
211211
- `pairs`: compact string `old1:new1,old2:new2`
212212
Returns per-item results plus totals. Order is respected; later pairs can refer to earlier new names.
213213

214+
## Development
215+
216+
### Code Quality
217+
218+
This project uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting. Configuration is in `ruff.toml`.
219+
220+
#### Running Ruff Manually
221+
222+
Check for issues:
223+
```bash
224+
ruff check .
225+
```
226+
227+
Auto-fix issues:
228+
```bash
229+
ruff check --fix .
230+
```
231+
232+
Check formatting issues:
233+
```bash
234+
ruff format --check .
235+
```
236+
237+
Format code:
238+
```bash
239+
ruff format .
240+
```
241+
242+
#### GitHub Actions
243+
244+
A GitHub Action workflow (`.github/workflows/lint-format.yml`) automatically runs Ruff on:
245+
246+
- Every push to the `main` branch
247+
- Every pull request targeting the `main` branch
248+
249+
The workflow will fail if there are linting errors or formatting issues, ensuring code quality in CI.
250+
214251
## Contributing
215252

216253
Contributions are welcome. Please feel free to submit a pull request.

ruff.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
target-version = "py312"
2+
line-length = 100
3+
4+
[lint]
5+
select = [
6+
"E", # pycodestyle errors
7+
"W", # pycodestyle warnings
8+
"F", # pyflakes
9+
"I", # isort
10+
"UP", # pyupgrade
11+
"RUF", # Ruff-specific rules
12+
]
13+
14+
[lint.isort]
15+
known-first-party = ["plugin", "bridge"]
16+
17+
[lint.per-file-ignores]
18+
"__init__.py" = ["F401"] # Allow unused imports in __init__.py files
19+
"scripts/*" = ["T201"] # Allow print statements in scripts

0 commit comments

Comments
 (0)