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..06202d5 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,29 @@ +target-version = "py311" +[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", "B905"] + + +[lint.pycodestyle] +ignore-overlong-task-comments = true + +[lint.pydocstyle] +convention = "google" diff --git a/run-tests.sh b/run-tests.sh index 7960aa6..26ffc30 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -22,5 +22,4 @@ set -e -flake8 inspire_json_merger tests pytest tests/ diff --git a/setup.py b/setup.py index 1e51bc0..6193ad5 100644 --- a/setup.py +++ b/setup.py @@ -55,9 +55,14 @@ 'pytest~=8.0,>=8.0.2;python_version >= "3.6"', ] +dev_require = [ + "pre-commit==3.5.0", +] + extras_require = { 'docs': docs_require, 'tests': tests_require, + 'dev': dev_require, } extras_require['all'] = []