Skip to content

Commit 022dfd5

Browse files
committed
fix(lint): fix mypy typing
1 parent 7bfb90b commit 022dfd5

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Setup Python
5555
uses: actions/setup-python@v4
5656
with:
57-
python-version: '3.10'
57+
python-version: '3.12'
5858
- name: Install Python dependencies
5959
run: |
6060
python -m pip install --upgrade hatch

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ ignore_missing_imports = true
144144
warn_unreachable = true
145145
no_implicit_optional = true
146146
show_error_codes = true
147+
plugins = [
148+
"pydantic.mypy"
149+
]
147150

148151
[tool.commitizen]
149152
version = "1.0.1rc2"

src/vaultwarden/models/bitwarden.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Generic, TypeVar
1+
from typing import Generic, Literal, TypeVar, cast
22
from uuid import UUID
33

44
from pydantic import AliasChoices, Field, TypeAdapter, field_validator
@@ -158,13 +158,15 @@ def set_users(
158158
users_payload = []
159159
if users is not None and len(users) > 0:
160160
if isinstance(users[0], CollectionUser):
161+
users = cast(list[CollectionUser], users)
161162
users_payload = [
162-
user.model_dump( # type: ignore
163+
user.model_dump(
163164
exclude={"CollectionId"}, by_alias=True, mode="json"
164165
)
165166
for user in users
166167
]
167168
else:
169+
users = cast(list[UUID], users)
168170
users_payload = [
169171
{
170172
"id": str(user_id),
@@ -351,28 +353,26 @@ def invite(
351353
):
352354
collections_payload = []
353355
if collections is not None and len(collections) > 0:
354-
assert collections is not None
355356
for coll in collections:
356357
if isinstance(coll, UserCollection):
357-
assert isinstance(coll, UserCollection)
358+
coll = cast(UserCollection, coll)
359+
ex: dict[str, Literal[True]] = {"UserId": True}
358360
collections_payload.append(
359361
coll.model_dump(
360362
by_alias=True,
361363
mode="json",
362-
exclude={"UserId": True},
364+
exclude=ex,
363365
)
364366
)
365367
else:
366-
coll_id = ""
367368
if isinstance(coll, OrganizationCollection):
368-
assert isinstance(coll, OrganizationCollection)
369+
coll = cast(OrganizationCollection, coll)
369370
coll_id = str(coll.Id)
370-
elif isinstance(collections[0], UUID):
371-
assert isinstance(coll, UUID)
371+
elif isinstance(coll, UUID):
372+
coll = cast(UUID, coll)
372373
coll_id = str(coll)
373374
else:
374-
assert isinstance(coll, str)
375-
coll_id = coll
375+
coll_id = cast(str, coll)
376376
collections_payload.append(
377377
{
378378
"id": coll_id,

0 commit comments

Comments
 (0)