From 6bbf70ae7a85707c1338d6f4bf1640cd1f95f848 Mon Sep 17 00:00:00 2001 From: Michael Katz Date: Mon, 15 Jan 2024 10:23:31 +0100 Subject: [PATCH] Correct type hints for client certificate --- tusclient/client.py | 8 ++++---- tusclient/uploader/baseuploader.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tusclient/client.py b/tusclient/client.py index 7af40db..7b8c784 100644 --- a/tusclient/client.py +++ b/tusclient/client.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional, Tuple +from typing import Dict, Optional, Tuple, Union from tusclient.uploader import Uploader, AsyncUploader @@ -16,7 +16,7 @@ class TusClient: along with every request made by the cleint to the server. This may be used to set authentication headers. These headers should not include headers required by tus protocol. If not set this defaults to an empty dictionary. - - client_cert (tuple): + - client_cert (str|tuple[str,str]): Path of PEM encoded client certitifacate and optionally path to PEM encoded key file. The PEM encoded key of the certificate can either be included in the certificate itself or be provided in a seperate file. @@ -24,10 +24,10 @@ class TusClient: :Constructor Args: - url (str) - headers (Optiional[dict]) - - client_cert (Optional[Tuple[str, str]]) + - client_cert (Optional[str | Tuple[str, str]]) """ - def __init__(self, url: str, headers: Optional[Dict[str, str]] = None, client_cert: Optional[Tuple[str, str]] = None): + def __init__(self, url: str, headers: Optional[Dict[str, str]] = None, client_cert: Optional[Union[str, Tuple[str, str]]] = None): self.url = url self.headers = headers or {} self.client_cert = client_cert diff --git a/tusclient/uploader/baseuploader.py b/tusclient/uploader/baseuploader.py index e7b5eaa..94f8df5 100644 --- a/tusclient/uploader/baseuploader.py +++ b/tusclient/uploader/baseuploader.py @@ -1,4 +1,4 @@ -from typing import Optional, IO, Dict, Tuple, TYPE_CHECKING +from typing import Optional, IO, Dict, Tuple, TYPE_CHECKING, Union import os import re from base64 import b64encode @@ -103,7 +103,7 @@ def __init__(self, file_path: Optional[str] = None, file_stream: Optional[IO] = url_storage: Optional[Storage] = None, fingerprinter: Optional[interface.Fingerprint] = None, upload_checksum=False, - client_cert: Optional[Tuple[str, str]] = None): + client_cert: Optional[ Union[str, Tuple[str, str] ]] = None): if file_path is None and file_stream is None: raise ValueError( "Either 'file_path' or 'file_stream' cannot be None.")