Skip to content

Commit

Permalink
Need to use Union for mixed return types.
Browse files Browse the repository at this point in the history
  • Loading branch information
melwil committed Oct 24, 2023
1 parent 5eeab2f commit 8ae6b03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/onepasswordconnectsdk/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import httpx
from httpx import HTTPError
import json
from typing import Dict, List
from typing import Dict, List, Union
import os

from onepasswordconnectsdk.serializer import Serializer
Expand Down Expand Up @@ -57,7 +57,7 @@ async def get_files(self, item_id: str, vault_id: str) -> List[File]:
)
return self.serializer.deserialize(response.content, "list[File]")

async def get_file_content(self, file_id: str, item_id: str, vault_id: str, content_path: str = None) -> bytes | str:
async def get_file_content(self, file_id: str, item_id: str, vault_id: str, content_path: str = None) -> Union[bytes, str]:
url = content_path
if content_path is None:
url = PathBuilder().vaults(vault_id).items(item_id).files(file_id).content().build()
Expand Down
8 changes: 4 additions & 4 deletions src/onepasswordconnectsdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import httpx
from httpx import HTTPError
import json
from typing import Dict, List
from typing import Dict, List, Union
import os

from onepasswordconnectsdk.async_client import AsyncClient
Expand Down Expand Up @@ -64,7 +64,7 @@ def get_files(self, item_id: str, vault_id: str) -> List[File]:
)
return self.serializer.deserialize(response.content, "list[File]")

def get_file_content(self, file_id: str, item_id: str, vault_id: str, content_path: str = None) -> bytes | str:
def get_file_content(self, file_id: str, item_id: str, vault_id: str, content_path: str = None) -> Union[bytes, str]:
url = content_path
if content_path is None:
url = PathBuilder().vaults(vault_id).items(item_id).files(file_id).content().build()
Expand Down Expand Up @@ -381,7 +381,7 @@ def sanitize_for_serialization(self, obj):
return self.serializer.sanitize_for_serialization(obj)


def new_client(url: str, token: str, is_async: bool = False) -> AsyncClient | Client:
def new_client(url: str, token: str, is_async: bool = False) -> Union[AsyncClient, Client]:
"""Builds a new client for interacting with 1Password Connect
Parameters:
url: The url of the 1Password Connect API
Expand All @@ -396,7 +396,7 @@ def new_client(url: str, token: str, is_async: bool = False) -> AsyncClient | Cl
return Client(url, token)


def new_client_from_environment(url: str = None) -> AsyncClient | Client:
def new_client_from_environment(url: str = None) -> Union[AsyncClient, Client]:
"""Builds a new client for interacting with 1Password Connect
using the OP_TOKEN environment variable
Expand Down

0 comments on commit 8ae6b03

Please sign in to comment.