From c093aa0e50024fca45ab9db44354a807574bd49a Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 15 May 2023 10:43:59 +0200 Subject: [PATCH] pre-commit: add autoflake and isort, include autoformatter config --- .pre-commit-config.yaml | 15 +++++++++++++++ pyproject.toml | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bbda53c..f62bd40 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,6 +20,21 @@ repos: # exclude it from the pyupgrade hook that will apply f-strings etc. exclude: bootstrap/bootstrap.py + # Autoformat: Python code + - repo: https://github.com/PyCQA/autoflake + rev: v2.1.1 + hooks: + - id: autoflake + # args ref: https://github.com/PyCQA/autoflake#advanced-usage + args: + - --in-place + + # Autoformat: Python code + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + # Autoformat: Python code - repo: https://github.com/psf/black rev: 23.3.0 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..170be20 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,34 @@ +# autoflake is used for autoformatting Python code +# +# ref: https://github.com/PyCQA/autoflake#readme +# +[tool.autoflake] +ignore-init-module-imports = true +remove-all-unused-imports = true +remove-duplicate-keys = true +remove-unused-variables = true + + +# isort is used for autoformatting Python code +# +# ref: https://pycqa.github.io/isort/ +# +[tool.isort] +profile = "black" + + +# black is used for autoformatting Python code +# +# ref: https://black.readthedocs.io/en/stable/ +# +[tool.black] +# target-version should be all supported versions, see +# https://github.com/psf/black/issues/751#issuecomment-473066811 +target_version = [ + "py36", + "py37", + "py38", + "py39", + "py310", + "py311", +]