From 3efd5a1678a9a8746e79f46e8da9588a6c18f73a Mon Sep 17 00:00:00 2001 From: PascalEgn Date: Tue, 6 Aug 2024 13:53:03 +0200 Subject: [PATCH] global: add pre-commit with ruff --- .pre-commit-config.yaml | 17 +++++++++++++++++ ruff.toml | 30 ++++++++++++++++++++++++++++++ setup.py | 7 ++++++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml create mode 100644 ruff.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..2c56732 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: fix-byte-order-marker + - id: mixed-line-ending + - id: name-tests-test + args: [ --pytest-test-first ] + exclude: '^(?!factories/)' + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.6 + hooks: + - id: ruff + args: [ --fix ] diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..8c073e3 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,30 @@ +target-version = "py311" +line-length = 100 +[lint.flake8-tidy-imports] +ban-relative-imports = "all" + +[lint] +select = [ + # pycodestyle + "E", + # Pyflakes + "F", + # flake8-bugbear + "B", + # flake8-simplify + "SIM", + # isort + "I", + # flake8-tidy-imports + "TID", + # flake8-pytest-style + "PT", +] +ignore = ["B904"] + + +[lint.pycodestyle] +ignore-overlong-task-comments = true + +[lint.pydocstyle] +convention = "google" diff --git a/setup.py b/setup.py index 2cd0e60..aca2dac 100644 --- a/setup.py +++ b/setup.py @@ -54,13 +54,18 @@ "pytest-cov~=2.0,>=2.6.1", ] +dev_require = [ + "pre-commit==3.5.0", +] + extras_require = { "docs": docs_require, "tests": tests_require, + "dev": dev_require, } extras_require["all"] = [] -for name, reqs in extras_require.items(): +for _name, reqs in extras_require.items(): extras_require["all"].extend(reqs) packages = find_packages(exclude=["docs"])