From 9eadbe6e025a154f0c9c935ae21a2c90f0077cbf Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Thu, 29 Aug 2024 05:17:27 +0430 Subject: [PATCH 1/3] :wrench: chore: Update pyproject.toml config - Add bandit for security check in python code - Add ruff hook - Add commitzen hook - Add pylint&pytest hook in local --- .pre-commit-config.yaml | 61 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb4606f..fb71888 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,21 +1,20 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: trailing-whitespace exclude: (migrations/|tests/|docs/|static/|media/).* - id: end-of-file-fixer exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-added-large-files + - id: check-merge-conflict exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-case-conflict + - id: check-yaml exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-merge-conflict + - id: check-added-large-files exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-docstring-first + - id: detect-private-key exclude: (migrations/|tests/|docs/|static/|media/).* - - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: @@ -26,4 +25,52 @@ repos: rev: 23.3.0 hooks: - id: black - exclude: (migrations/|tests/|docs/|static/|media/).* \ No newline at end of file + args: ["--config=pyproject.toml"] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.5.5 + hooks: + - id: ruff + args: ["--config=pyproject.toml"] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.28.0 + hooks: + - id: commitizen + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/PyCQA/bandit + rev: 1.7.4 + hooks: + - id: bandit + args: ["-c", "pyproject.toml", "-r", "."] + additional_dependencies: [ "bandit[toml]" ] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: local + hooks: + - id: pytest + name: Pytest + entry: poetry run pytest -v + language: system + types: [python] + stages: [commit] + pass_filenames: false + always_run: true + + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + require_serial: true + args: + - "-rn" + - "-sn" + - "--rcfile=pyproject.toml" + files: ^sage_tools/ + +ci: + skip: [pylint] \ No newline at end of file From 7c8b79ec6a3c22a70ba385db05502ff627315076 Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Fri, 30 Aug 2024 22:45:13 +0430 Subject: [PATCH 2/3] :wrench: chore: Update pre-commit config - Add pyproject.toml config hook - Add tox.ini config hook - Add pyupgrade hook - Add blacken docs hook for docs --- .pre-commit-config.yaml | 68 ++++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb71888..a18d090 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,20 +1,45 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.3.0 hooks: + - id: check-toml + - id: check-yaml + files: \.yaml$ - id: trailing-whitespace exclude: (migrations/|tests/|docs/|static/|media/).* - id: end-of-file-fixer exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-merge-conflict + - id: check-added-large-files exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-yaml + - id: check-case-conflict exclude: (migrations/|tests/|docs/|static/|media/).* - - id: check-added-large-files + - id: check-merge-conflict exclude: (migrations/|tests/|docs/|static/|media/).* - - id: detect-private-key + - id: check-docstring-first exclude: (migrations/|tests/|docs/|static/|media/).* + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 2.2.1 + hooks: + - id: pyproject-fmt + + - repo: https://github.com/tox-dev/tox-ini-fmt + rev: 1.3.1 + hooks: + - id: tox-ini-fmt + + - repo: https://github.com/asottile/pyupgrade + rev: v3.17.0 + hooks: + - id: pyupgrade + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.5.5 + hooks: + - id: ruff + args: ["--config=pyproject.toml"] + exclude: (migrations/|tests/|docs/|static/|media/|apps.py).* + - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: @@ -28,18 +53,10 @@ repos: args: ["--config=pyproject.toml"] exclude: (migrations/|tests/|docs/|static/|media/).* - - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.5.5 - hooks: - - id: ruff - args: ["--config=pyproject.toml"] - exclude: (migrations/|tests/|docs/|static/|media/).* - - repo: https://github.com/commitizen-tools/commitizen rev: v3.28.0 hooks: - id: commitizen - exclude: (migrations/|tests/|docs/|static/|media/).* - repo: https://github.com/PyCQA/bandit rev: 1.7.4 @@ -49,6 +66,29 @@ repos: additional_dependencies: [ "bandit[toml]" ] exclude: (migrations/|tests/|docs/|static/|media/).* + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.5 + hooks: + - id: docformatter + args: ["--in-place", "--recursive", "--blank"] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/adamchainz/blacken-docs + rev: 1.18.0 + hooks: + - id: blacken-docs + additional_dependencies: + - black==24.4.2 + files: '\.rst$' + + - repo: https://github.com/rstcheck/rstcheck + rev: "v6.2.4" + hooks: + - id: rstcheck + args: ["--report-level=warning"] + files: ^(docs/(.*/)*.*\.rst) + additional_dependencies: [Sphinx==6.2.1] + - repo: local hooks: - id: pytest @@ -73,4 +113,4 @@ repos: files: ^sage_tools/ ci: - skip: [pylint] \ No newline at end of file + skip: [pylint] From b8d8f31f56395707f769f2a3aaae77a23b6cee2c Mon Sep 17 00:00:00 2001 From: ARYAN-NIKNEZHAD Date: Fri, 6 Sep 2024 05:58:01 +0430 Subject: [PATCH 3/3] :wrench: chore: Add pre-commit-config-ci for CI actions --- .pre-commit-config-ci.yml | 101 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .pre-commit-config-ci.yml diff --git a/.pre-commit-config-ci.yml b/.pre-commit-config-ci.yml new file mode 100644 index 0000000..1401d0d --- /dev/null +++ b/.pre-commit-config-ci.yml @@ -0,0 +1,101 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-toml + - id: check-yaml + files: \.yaml$ + - id: trailing-whitespace + exclude: (migrations/|tests/|docs/|static/|media/).* + - id: end-of-file-fixer + exclude: (migrations/|tests/|docs/|static/|media/).* + - id: check-added-large-files + exclude: (migrations/|tests/|docs/|static/|media/).* + - id: check-case-conflict + exclude: (migrations/|tests/|docs/|static/|media/).* + - id: check-merge-conflict + exclude: (migrations/|tests/|docs/|static/|media/).* + - id: check-docstring-first + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/tox-dev/pyproject-fmt + rev: 2.2.1 + hooks: + - id: pyproject-fmt + + - repo: https://github.com/tox-dev/tox-ini-fmt + rev: 1.3.1 + hooks: + - id: tox-ini-fmt + + - repo: https://github.com/asottile/pyupgrade + rev: v3.15.2 + hooks: + - id: pyupgrade + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.5.5 + hooks: + - id: ruff + args: ["--config=pyproject.toml"] + exclude: (migrations/|tests/|docs/|static/|media/|apps.py).* + + - repo: https://github.com/pre-commit/mirrors-isort + rev: v5.10.1 + hooks: + - id: isort + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black + args: [ "--config=pyproject.toml" ] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/commitizen-tools/commitizen + rev: v3.28.0 + hooks: + - id: commitizen + + - repo: https://github.com/PyCQA/bandit + rev: 1.7.4 + hooks: + - id: bandit + args: [ "-c", "pyproject.toml", "-r", "." ] + additional_dependencies: [ "bandit[toml]" ] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.5 + hooks: + - id: docformatter + args: [ "--in-place", "--recursive", "--blank" ] + exclude: (migrations/|tests/|docs/|static/|media/).* + + - repo: https://github.com/adamchainz/blacken-docs + rev: 1.18.0 + hooks: + - id: blacken-docs + additional_dependencies: + - black==24.4.2 + files: '\.rst$' + + - repo: https://github.com/rstcheck/rstcheck + rev: "v6.2.4" + hooks: + - id: rstcheck + args: [ "--report-level=warning" ] + files: ^(docs/(.*/)*.*\.rst) + additional_dependencies: [ Sphinx==6.2.1 ] + + - repo: local + hooks: + - id: pytest + name: Pytest + entry: poetry run pytest -v + language: system + types: [ python ] + stages: [ commit ] + pass_filenames: false + always_run: true \ No newline at end of file