diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 41495f1616..d87941e09f 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -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') diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6a51741b85..8b38d69a31 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 ] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 9787c3bdf0..8d58511e99 100644 --- a/pyproject.toml +++ b/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"] \ No newline at end of file