Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automated style/linting checks with Ruff #138

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run Ruff linting
run: ruff check --output-format=github .
- name: Run Ruff formatting
run: ruff format --check .
40 changes: 18 additions & 22 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["B", "E", "F", "D", "I"]
ignore = ["D200","D202","D210","D212","D415","D105",]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
unfixable = []
# Project configuration
line-length = 100
target-version = "py311"
output-format = "github" # Add GitHub-specific output formatting
fix = true

# Exclude a variety of commonly ignored directories.
exclude = [
Expand All @@ -31,27 +29,25 @@ exclude = [
"tests",
]

# Same as Black.
line-length = 100
[lint]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["B", "E", "F", "D", "I"]
ignore = ["D200", "D202", "D210", "D212", "D415", "D105"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["A", "B", "C", "D", "E", "F", "I"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.10.
target-version = "py310"
fix = false
# Per-file ignore rules
per-file-ignores = { "__init__.py" = ["F401", "E402"] }

# Group violations by containing file.
format = "github"
ignore-init-module-imports = true
peterdudfield marked this conversation as resolved.
Show resolved Hide resolved

[mccabe]
[lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

[pydocstyle]
[lint.pydocstyle]
# Use Google-style docstrings.
convention = "google"

[per-file-ignores]
"__init__.py" = ["F401", "E402"]
convention = "google"
Loading