From 03d888a62d57d084efa7843022064b43a73077ce Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Thu, 23 May 2024 20:32:21 +0000 Subject: [PATCH] build: add pre-commit --- .devcontainer/devcontainer.json | 20 +++-------- .pre-commit-config.yaml | 60 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2e3b3a18..3310019c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,33 +4,24 @@ "dockerfile": "Dockerfile", "context": "..", "args": { - // Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6 - // Append -bullseye or -buster to pin to an OS version. - // Use -bullseye variants on local on arm64/Apple Silicon. "VARIANT": "3.10-bullseye", - // Options + "INSTALL_NODE": "false", "NODE_VERSION": "lts/*" } }, "customizations": { "vscode": { - // Set *default* container specific settings.json values on container create. "settings": { "editor.formatOnPaste": false, "editor.formatOnSave": true, "editor.formatOnType": true, "python.formatting.provider": "black", - "python.testing.pytestArgs": [ - "tests" - ], + "python.testing.pytestArgs": ["tests"], "python.testing.pytestEnabled": true, "python.testing.unittestEnabled": false, - "pylint.args": [ - - ], + "pylint.args": [], "files.trimTrailingWhitespace": true }, - // Add the IDs of extensions you want installed when the container is created. "extensions": [ "charliermarsh.ruff", "ms-python.pylint", @@ -42,7 +33,6 @@ ] } }, - "remoteUser": "root", - "containerUser": "vscode", + "remoteUser": "vscode", "postAttachCommand": ["pip3 install --user -r requirements.txt"] -} \ No newline at end of file +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..9383cc04 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,60 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: "CHANGELOG.md|.copier-answers.yml" +default_stages: [commit] + +ci: + autofix_commit_msg: "chore(pre-commit.ci): auto fixes" + autoupdate_commit_msg: "chore(pre-commit.ci): pre-commit autoupdate" + autoupdate_schedule: weekly + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: no-commit-to-branch + args: ["--branch", "main"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.4 + hooks: + - id: ruff + args: + - --fix + - id: ruff-format + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.26.0 + hooks: + - id: commitizen + stages: [commit-msg] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-json + - id: check-toml + - id: check-xml + - id: check-yaml + - id: detect-private-key + - repo: https://github.com/python-poetry/poetry + rev: 1.8.0 + hooks: + - id: poetry-check + args: ["--lock"] + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + args: ["--tab-width", "2"] + - repo: https://github.com/asottile/pyupgrade + rev: v3.15.2 + hooks: + - id: pyupgrade + args: [--py37-plus] + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.10.0 + hooks: + - id: mypy + additional_dependencies: []