diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 3a87b269..00000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -exclude = docs -max-line-length = 119 -extend-ignore = E203 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86b60146..fbcd6f37 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,27 +25,12 @@ repos: - id: prettier args: ["--tab-width", "2"] - - repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.4 hooks: - - id: pyupgrade - args: [--py312-plus] - exclude: hooks/ - - - repo: https://github.com/psf/black - rev: 24.10.0 - hooks: - - id: black - - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - - - repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 - hooks: - - id: flake8 + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: https://github.com/tox-dev/pyproject-fmt rev: "v2.5.0" diff --git a/pyproject.toml b/pyproject.toml index 5e7cfc7f..9e718a3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,22 +58,86 @@ docs = [ "sphinx-rtd-theme>=3", ] -[tool.black] -line-length = 119 -target-version = [ - 'py312', +[tool.ruff] +target-version = "py312" +# Exclude the template content as most files aren't parseable +extend-exclude = [ + "{{cookiecutter.project_slug}}/*", ] -# ==== isort ==== - -[tool.isort] -profile = "black" -line_length = 119 -known_first_party = [ - "tests", - "scripts", - "hooks", +[tool.ruff.lint] +select = [ + "F", + "E", + "W", + "C90", + "I", + "N", + "UP", + "YTT", + # "ANN", # flake8-annotations: we should support this in the future but 100+ errors atm + "ASYNC", + "S", + "BLE", + "FBT", + "B", + "A", + "COM", + "C4", + "DTZ", + "T10", + "EM", + "EXE", + "FA", + 'ISC', + "ICN", + "G", + 'INP', + 'PIE', + "T20", + 'PYI', + 'PT', + "Q", + "RSE", + "RET", + "SLF", + "SLOT", + "SIM", + "TID", + "TCH", + "INT", + # "ARG", # Unused function argument + "PTH", + "ERA", + "PD", + "PGH", + "PL", + "TRY", + "FLY", + # "NPY", + # "AIR", + "PERF", + # "FURB", + # "LOG", + "RUF", ] +ignore = [ + "S101", # Use of assert detected https://docs.astral.sh/ruff/rules/assert/ + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "SIM102", # sometimes it's better to nest + "UP038", # Checks for uses of isinstance/issubclass that take a tuple + # of types for comparison. + # Deactivated because it can make the code slow: + # https://github.com/astral-sh/ruff/issues/7871 +] +# The fixes in extend-unsafe-fixes will require +# provide the `--unsafe-fixes` flag when fixing. +extend-unsafe-fixes = [ + "UP038", +] + +[tool.ruff.lint.isort] +force-single-line = true # ==== pytest ==== diff --git a/tox.ini b/tox.ini index 70cde339..15c50abc 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,3 @@ envlist = py312,black-template [testenv] passenv = AUTOFIXABLE_STYLES commands = pytest -n auto {posargs:./tests} - -[testenv:black-template] -deps = black -commands = black --check hooks tests docs scripts