From 75a34faa5b3c651fc14c090b99921dac3343a7f6 Mon Sep 17 00:00:00 2001 From: Lujeni Date: Tue, 5 May 2026 14:10:12 +0200 Subject: [PATCH] ci: delegate lint, format and typecheck to pre-commit --- .github/workflows/ci.yml | 16 +++------------- .pre-commit-config.yaml | 8 -------- README.md | 18 ++++++------------ pyproject.toml | 28 ---------------------------- src/vaultwarden/models/bitwarden.py | 2 +- 5 files changed, 10 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99a6173..a527c2e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,19 +50,9 @@ jobs: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: "3.13" - - name: Install Python dependencies - run: | - python -m pip install --upgrade hatch - - name: Check with black + isort - if: always() - run: hatch run style:format && git diff --exit-code - - name: Check with ruff - if: always() - run: hatch run style:lint - - name: Check with mypy - if: always() - run: hatch run types:check + python-version: "3.12" + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 package: runs-on: ubuntu-latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c37d1e..8ecfb3b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,14 +21,6 @@ repos: - id: mypy additional_dependencies: [types-PyYAML, types-setuptools, typing-extensions, pydantic>=2.5.0] - args: - [ - --ignore-missing-imports, - --warn-unreachable, - --no-implicit-optional, - --show-error-codes, - --plugins=pydantic.mypy, - ] - repo: https://github.com/commitizen-tools/commitizen rev: v3.5.3 diff --git a/README.md b/README.md index 01d0dc4..22f648a 100644 --- a/README.md +++ b/README.md @@ -135,23 +135,17 @@ You can now install the project and its dependencies using: pip install -e .[test] ``` -### Code Style and Linting +### Pre-commit hooks -This project uses [ruff](https://docs.astral.sh/ruff/) for both linting and code formatting. Before submitting a pull request, ensure your code follows the project's style guidelines. - -To check for linting and formatting issues: -```bash -hatch run style:check -``` - -To automatically fix linting issues and format your code: +Install [pre-commit](https://pre-commit.com/) hooks to run the same checks as CI before each commit: ```bash -hatch run style:format +pip install pre-commit +pre-commit install ``` -To only run linting (with auto-fix): +Run all hooks manually: ```bash -hatch run style:lint +pre-commit run --all-files ``` ### Testing diff --git a/pyproject.toml b/pyproject.toml index 55114db..61561a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,34 +81,6 @@ matrix.type.scripts = [ { key = "with-coverage", value = "_coverage", if = ["default"] }, ] -[tool.hatch.envs.types] -dependencies = [ - "mypy", - "types-PyYAML", - "types-setuptools", - "typing-extensions", -] -[tool.hatch.envs.types.scripts] -check = "mypy src/vaultwarden" - -[tool.hatch.envs.style] -detached = true -dependencies = [ - "ruff", -] -[tool.hatch.envs.style.scripts] -lint = [ - "ruff check --fix src/vaultwarden tests", -] -check = [ - "ruff check src/vaultwarden tests", - "ruff format --check src/vaultwarden tests", -] -format = [ - "ruff format src/vaultwarden tests", - "lint", -] - [tool.ruff] src = ["src/vaultwarden", "tests"] exclude = ["src/vaultwarden/utils/crypto.py"] diff --git a/src/vaultwarden/models/bitwarden.py b/src/vaultwarden/models/bitwarden.py index 17de6c0..5d01732 100644 --- a/src/vaultwarden/models/bitwarden.py +++ b/src/vaultwarden/models/bitwarden.py @@ -6,7 +6,6 @@ Any, Generic, Literal, - Self, TypeVar, Union, cast, @@ -27,6 +26,7 @@ ValidationInfo, ValidatorFunctionWrapHandler, ) +from typing_extensions import Self from vaultwarden.clients.bitwarden import BitwardenAPIClient from vaultwarden.models.enum import CipherType, KdfType, OrganizationUserType