Skip to content

Commit ac968dc

Browse files
committed
ci: delegate lint, format and typecheck to pre-commit
1 parent f95c365 commit ac968dc

6 files changed

Lines changed: 13 additions & 64 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,9 @@ jobs:
5050
- name: Setup Python
5151
uses: actions/setup-python@v4
5252
with:
53-
python-version: "3.13"
54-
- name: Install Python dependencies
55-
run: |
56-
python -m pip install --upgrade hatch
57-
- name: Check with black + isort
58-
if: always()
59-
run: hatch run style:format && git diff --exit-code
60-
- name: Check with ruff
61-
if: always()
62-
run: hatch run style:lint
63-
- name: Check with mypy
64-
if: always()
65-
run: hatch run types:check
53+
python-version: "3.12"
54+
- name: Run pre-commit
55+
uses: pre-commit/action@v3.0.1
6656

6757
package:
6858
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,9 @@ repos:
1919
rev: v1.13.0
2020
hooks:
2121
- id: mypy
22+
exclude: ^tests/
2223
additional_dependencies:
2324
[types-PyYAML, types-setuptools, typing-extensions, pydantic>=2.5.0]
24-
args:
25-
[
26-
--ignore-missing-imports,
27-
--warn-unreachable,
28-
--no-implicit-optional,
29-
--show-error-codes,
30-
--plugins=pydantic.mypy,
31-
]
3225

3326
- repo: https://github.com/commitizen-tools/commitizen
3427
rev: v3.5.3

README.md

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,23 +135,17 @@ You can now install the project and its dependencies using:
135135
pip install -e .[test]
136136
```
137137

138-
### Code Style and Linting
138+
### Pre-commit hooks
139139

140-
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.
141-
142-
To check for linting and formatting issues:
143-
```bash
144-
hatch run style:check
145-
```
146-
147-
To automatically fix linting issues and format your code:
140+
Install [pre-commit](https://pre-commit.com/) hooks to run the same checks as CI before each commit:
148141
```bash
149-
hatch run style:format
142+
pip install pre-commit
143+
pre-commit install
150144
```
151145

152-
To only run linting (with auto-fix):
146+
Run all hooks manually:
153147
```bash
154-
hatch run style:lint
148+
pre-commit run --all-files
155149
```
156150

157151
### Testing

pyproject.toml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,6 @@ matrix.type.scripts = [
8181
{ key = "with-coverage", value = "_coverage", if = ["default"] },
8282
]
8383

84-
[tool.hatch.envs.types]
85-
dependencies = [
86-
"mypy",
87-
"types-PyYAML",
88-
"types-setuptools",
89-
"typing-extensions",
90-
]
91-
[tool.hatch.envs.types.scripts]
92-
check = "mypy src/vaultwarden"
93-
94-
[tool.hatch.envs.style]
95-
detached = true
96-
dependencies = [
97-
"ruff",
98-
]
99-
[tool.hatch.envs.style.scripts]
100-
lint = [
101-
"ruff check --fix src/vaultwarden tests",
102-
]
103-
check = [
104-
"ruff check src/vaultwarden tests",
105-
"ruff format --check src/vaultwarden tests",
106-
]
107-
format = [
108-
"ruff format src/vaultwarden tests",
109-
"lint",
110-
]
111-
11284
[tool.ruff]
11385
src = ["src/vaultwarden", "tests"]
11486
exclude = ["src/vaultwarden/utils/crypto.py"]

src/vaultwarden/models/bitwarden.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Any,
77
Generic,
88
Literal,
9-
Self,
109
TypeVar,
1110
Union,
1211
cast,
@@ -27,6 +26,7 @@
2726
ValidationInfo,
2827
ValidatorFunctionWrapHandler,
2928
)
29+
from typing_extensions import Self
3030

3131
from vaultwarden.clients.bitwarden import BitwardenAPIClient
3232
from vaultwarden.models.enum import CipherType, KdfType, OrganizationUserType
@@ -449,7 +449,7 @@ class OrganizationUserDetails(BitwardenBaseModel):
449449
Collections: list[UserCollection]
450450
Groups: list | None = None
451451
TwoFactorEnabled: bool
452-
Permissions: dict | None = Field(default_factory=dict)
452+
Permissions: dict[str, Any] = Field(default_factory=dict)
453453

454454
@field_validator("OrganizationId")
455455
@classmethod

tests/models/validation/test_pascal_camel_cases.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import unittest
22

33
from pydantic import TypeAdapter
4-
from src.vaultwarden.models.sync import SyncData, VaultwardenUser
54
from vaultwarden.models.bitwarden import (
65
Organization,
76
OrganizationCollection,
87
ResplistBitwarden,
98
)
9+
from vaultwarden.models.sync import SyncData, VaultwardenUser
1010

1111

1212
class TestModelCases(unittest.TestCase):

0 commit comments

Comments
 (0)