From 5a9e5d3e1bc489d9fb31556c33ffa04bf8480622 Mon Sep 17 00:00:00 2001 From: Wolfgang Malgadey Date: Sat, 21 Dec 2024 13:24:07 +0100 Subject: [PATCH] added pre commit features (#110) --- .github/workflows/lint-and-test-matrix.yml | 6 +-- .github/workflows/report-test-results.yml | 3 +- .pre-commit-config.yaml | 62 ++++++++++++++++++++++ pyproject.toml | 6 ++- requirements.txt | 2 - 5 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 .pre-commit-config.yaml delete mode 100644 requirements.txt diff --git a/.github/workflows/lint-and-test-matrix.yml b/.github/workflows/lint-and-test-matrix.yml index f3f39c8..9fd3bfa 100644 --- a/.github/workflows/lint-and-test-matrix.yml +++ b/.github/workflows/lint-and-test-matrix.yml @@ -28,8 +28,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -e . + pip install -e '.[all]' - name: Lint with black uses: psf/black@stable @@ -56,8 +55,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -e . + pip install -e '.[all]' - name: Run Tests with Coverage run: | diff --git a/.github/workflows/report-test-results.yml b/.github/workflows/report-test-results.yml index df8d425..b4db57a 100644 --- a/.github/workflows/report-test-results.yml +++ b/.github/workflows/report-test-results.yml @@ -22,8 +22,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -e . + pip install -e '.[all]' - name: Run Tests with Coverage run: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..98e5388 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,62 @@ +fail_fast: true + +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-ast + - id: check-json + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + exclude: custom_components/econnect_metronet/manifest.json + - id: mixed-line-ending + - id: trailing-whitespace + +- repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + exclude: tests/ + args: ["--profile", "black"] + +- repo: https://github.com/asottile/pyupgrade + rev: v3.19.1 + hooks: + - id: pyupgrade + +- repo: https://github.com/psf/black + rev: 24.10.0 + hooks: + - id: black + exclude: tests/ + args: [--line-length=120] + +- repo: https://github.com/PyCQA/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + exclude: tests/ + args: [--max-line-length=120 ] + +- repo: https://github.com/PyCQA/bandit + rev: '1.8.0' + hooks: + - id: bandit + exclude: tests/ + +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.8.4 + hooks: + - id: ruff + exclude: tests/ + args: [--line-length=120] + +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.13.0 + hooks: + - id: mypy + exclude: tests/ + additional_dependencies: [types-requests] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 13f7db9..bc53d27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,11 @@ classifiers = [ GitHub = "https://github.com/wmalgadey/PyTado" [project.optional-dependencies] -dev = ["black>=24.3", "pytype", "pylint", "types-requests", "responses", "coverage", "pytest", "pytest-cov"] +dev = ["black>=24.3", "pre-commit", "pytype", "pylint", "types-requests", "requests", "responses", "coverage", "pytest", "pytest-cov"] + +all = [ + "python-tado[dev]", +] [project.scripts] pytado = "pytado.__main__:main" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 76c28c5..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests -responses