From f01e425ced3d47e46813927660642d16dd06f259 Mon Sep 17 00:00:00 2001 From: Steffen Schneider Date: Mon, 24 Jul 2023 16:00:09 +0200 Subject: [PATCH 1/2] Add ruff config --- .pre-commit-config.yaml | 4 ++++ pyproject.toml | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d5eb0609..fbd45842 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,3 +20,7 @@ repos: - id: isort additional_dependencies: - pyproject.toml + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.280 + hooks: + - id: ruff diff --git a/pyproject.toml b/pyproject.toml index a5c75353..d5f64ae8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -527,3 +527,56 @@ overgeneral-exceptions=[ 'Exception', 'BaseException', ] + +[tool.ruff] +# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default. +select = ["E", "F"] +ignore = [] + +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"] +unfixable = [] + +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] + +# Same as Black. +line-length = 160 + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +# Assume Python 3.10. +target-version = "py310" + +ignore-init-module-imports = true + +[tool.ruff.mccabe] +# Unlike Flake8, default to a complexity level of 10. +max-complexity = 10 + +[tool.ruff.per-file-ignores] +# ignore import issues in __init__ files +"__init__.py" = ["E402"] From bc117fe1d0593066f5e78159a834fbee039d8bff Mon Sep 17 00:00:00 2001 From: Steffen Schneider Date: Mon, 24 Jul 2023 16:03:13 +0200 Subject: [PATCH 2/2] Update config --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d5f64ae8..4a927c6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -579,4 +579,4 @@ max-complexity = 10 [tool.ruff.per-file-ignores] # ignore import issues in __init__ files -"__init__.py" = ["E402"] +"__init__.py" = ["E402", "F403", "F405", "F401"]