Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
strategy:
fail-fast: false
matrix:
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
os: [ ubuntu-latest ]
vaultwarden-version: [ '1.32.7', '1.33.2' , '1.34.3']
python-version: ["3.10", "3.11", "3.12", "3.13"]
os: [ubuntu-latest]
vaultwarden-version: ["1.32.7", "1.33.2", "1.34.3"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -54,7 +50,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.13'
python-version: "3.13"
- name: Install Python dependencies
run: |
python -m pip install --upgrade hatch
Expand All @@ -75,10 +71,11 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.10"
- name: Install Hatch
run: |
python -m pip install -U hatch
- name: Build package
run: |
hatch build
hatch build

25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,38 @@ You can now install the project and its dependencies using:
```bash
pip install -e .[test]
```

### Code Style and Linting

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:
```bash
hatch run style:format
```

To only run linting (with auto-fix):
```bash
hatch run style:lint
```

### Testing
To run the tests, use:

```bash
bash tests/e2e/run_tests.sh
```

Or using hatch:
```bash
hatch run test:test
```

## License

Python-vaultwarden is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
42 changes: 19 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,51 +93,47 @@ check = "mypy src/vaultwarden"
[tool.hatch.envs.style]
detached = true
dependencies = [
"black",
"isort",
"ruff",
]
[tool.hatch.envs.style.scripts]
lint = [
"ruff check --fix src/vaultwarden",
"ruff check --fix src/vaultwarden tests",
]
check = [
"isort --check-only --diff src/vaultwarden",
"black -q --check --diff src/vaultwarden",
"ruff check src/vaultwarden",
"ruff check src/vaultwarden tests",
"ruff format --check src/vaultwarden tests",
]
format = [
"isort -q src/vaultwarden",
"black -q src/vaultwarden",
"lint"
"ruff format src/vaultwarden tests",
"lint",
]

[tool.ruff]
# Add "Q" to the list of enabled codes.
select = ["B", "E", "F", "I", "N", "Q", "RUF", "SIM", "TCH"]
ignore = ["N815"]
fixable = ["ALL"]
src = ["src/vaultwarden", "tests"]
exclude = ["src/vaultwarden/utils/crypto.py"]
target-version = "py310"
line-length = 79

[tool.ruff.flake8-quotes]
[tool.ruff.lint]
# Add "Q" to the list of enabled codes.
select = ["B", "E", "F", "I", "N", "Q", "RUF", "SIM", "TCH"]
ignore = ["N815"]
fixable = ["ALL"]

[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.flake8-bugbear]
[tool.ruff.lint.flake8-bugbear]
extend-immutable-calls = ["typer.Argument"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-sort-within-sections = true

[tool.black]
line-length = 79
target-version = ["py310", "py311"]

[tool.isort]
profile = "black"
line_length = 80
[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.mypy]
ignore_missing_imports = true
Expand Down
4 changes: 1 addition & 3 deletions src/vaultwarden/clients/bitwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def __init__(
self._http_client = Client(
base_url=f"{self.url}/",
event_hooks={"response": [log_raise_for_status]},
headers={
"Bitwarden-Client-Version": "2024.1.0"
},
headers={"Bitwarden-Client-Version": "2024.1.0"},
timeout=timeout,
)
self._connect_token: ConnectToken | None = None
Expand Down
5 changes: 3 additions & 2 deletions src/vaultwarden/models/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ class UserProfile(PermissiveBaseModel):
Providers: list
SecurityStamp: str
TwoFactorEnabled: bool
# original Bitwarden doesn't support disabling users
status: VaultwardenUserStatus = Field(
default=VaultwardenUserStatus.Enabled, # original Bitwarden doesn't support disabling users
validation_alias=AliasChoices("_status", "_Status")
default=VaultwardenUserStatus.Enabled,
validation_alias=AliasChoices("_status", "_Status"),
)


Expand Down
5 changes: 2 additions & 3 deletions tests/models/validation/test_bitwarden_models.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import unittest

from pydantic import TypeAdapter

from vaultwarden.models.bitwarden import (
CollectionUser,
Organization,
ResplistBitwarden,
OrganizationUserDetails,
CollectionUser,
ResplistBitwarden,
)


Expand Down
3 changes: 1 addition & 2 deletions tests/models/validation/test_pascal_camel_cases.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import unittest

from pydantic import TypeAdapter

from src.vaultwarden.models.sync import SyncData, VaultwardenUser
from vaultwarden.models.bitwarden import (
Organization,
ResplistBitwarden,
OrganizationCollection,
ResplistBitwarden,
)


Expand Down
1 change: 0 additions & 1 deletion tests/models/validation/test_vaultwarden_models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import unittest

from pydantic import TypeAdapter

from vaultwarden.models.sync import VaultwardenUser


Expand Down