Skip to content

Commit

Permalink
feat(objects): fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Lowaiz committed Dec 13, 2023
1 parent f5fdb3b commit 8b79859
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
53 changes: 29 additions & 24 deletions src/vaultwarden/models/bitwarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,38 +345,43 @@ def invite(
| list[OrganizationCollection]
| list[UUID]
| list[str]
| None,
| None = None,
access_all: bool = False,
user_type: OrganizationUserType = OrganizationUserType.User,
default_readonly: bool = False,
default_hide_passwords: bool = False,
):
collections_payload = []
if collections is not None and len(collections) > 0:
if isinstance(collections[0], UserCollection):
collections_payload = TypeAdapter(
list[UserCollection]
).dump_python(
collections, # type: ignore
mode="json",
by_alias=True,
exclude={"__all__": {"UserId"}},
)
else:
if isinstance(collections[0], OrganizationCollection):
coll_uuids = [str(coll.Id) for coll in collections]
elif isinstance(collections[0], UUID):
coll_uuids = [str(coll) for coll in collections]
assert collections is not None
for coll in collections:
if isinstance(coll, UserCollection):
assert isinstance(coll, UserCollection)
collections_payload.append(
coll.model_dump(
by_alias=True,
mode="json",
exclude={"UserId": True},
)
)
else:
coll_uuids = collections
collections_payload = [
{
"id": collection,
"readOnly": default_readonly,
"hidePasswords": default_hide_passwords,
}
for collection in coll_uuids
]
coll_id = ""
if isinstance(coll, OrganizationCollection):
assert isinstance(coll, OrganizationCollection)
coll_id = str(coll.Id)
elif isinstance(collections[0], UUID):
assert isinstance(coll, UUID)
coll_id = str(coll)
else:
assert isinstance(coll, str)
coll_id = coll
collections_payload.append(
{
"id": coll_id,
"readOnly": default_readonly,
"hidePasswords": default_hide_passwords,
}
)

payload = {
"emails": [email],
Expand Down
2 changes: 1 addition & 1 deletion src/vaultwarden/models/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class UserProfile(BaseModel, extra="allow"):
Providers: list = []
SecurityStamp: str
TwoFactorEnabled: bool
_Status: VaultwardenUserStatus = None
_Status: VaultwardenUserStatus | None = None

@property
def status(self):
Expand Down

0 comments on commit 8b79859

Please sign in to comment.