Skip to content

Commit

Permalink
Testing: Add isort-only Ruff to pre-commit and autotest; #6538
Browse files Browse the repository at this point in the history
Adding Ruff to both the pre-commit script
(with --fix passed, thus sorting imports automatically)
and to GH autotest (checking only).
Ruff is currently only configured to check for import sorting.
Other linting functions (flake8, pyupgrade) will be added progressively.
  • Loading branch information
rdimaio authored and bari12 committed Mar 20, 2024
1 parent 03630bc commit 1ab4bfc
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/autotest.yml
Expand Up @@ -20,6 +20,20 @@ jobs:
shell: bash
run: |
python3 tools/add_header --dry-run --disable-progress-bar
python_ruff:
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
run: ruff check --output-format=github .
python_annotations:
if: |
!startsWith(github.ref_name, 'release')
Expand Down
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -15,3 +15,8 @@ repos:
description: Run the `add_header` script to verify the file headers
entry: tools/add_header
language: system
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.3
hooks:
- id: ruff
args: [ --fix ]
46 changes: 46 additions & 0 deletions pyproject.toml
@@ -1,3 +1,49 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.ruff]
line-length = 256

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]

[tool.ruff.lint]
select = [
"I", # isort
]

ignore = [
"ALL",
"UP031", # Use format specifiers instead of percent format
"SIM210",
]

extend-safe-fixes = ["I001"]

0 comments on commit 1ab4bfc

Please sign in to comment.