From 8ae6b03acc3f9b34be28f2b98779d530c73a72a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Slettvold?= Date: Tue, 24 Oct 2023 16:38:38 +0200 Subject: [PATCH] Need to use Union for mixed return types. --- src/onepasswordconnectsdk/async_client.py | 4 ++-- src/onepasswordconnectsdk/client.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/onepasswordconnectsdk/async_client.py b/src/onepasswordconnectsdk/async_client.py index 4dd5467..7df6ad1 100644 --- a/src/onepasswordconnectsdk/async_client.py +++ b/src/onepasswordconnectsdk/async_client.py @@ -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 @@ -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() diff --git a/src/onepasswordconnectsdk/client.py b/src/onepasswordconnectsdk/client.py index b0674a7..a62bae1 100644 --- a/src/onepasswordconnectsdk/client.py +++ b/src/onepasswordconnectsdk/client.py @@ -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 @@ -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() @@ -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 @@ -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