From f8e28f6b6e8075820a2229219a5dc9d87483ea78 Mon Sep 17 00:00:00 2001 From: Unrud Date: Sun, 5 Mar 2023 16:52:07 +0100 Subject: [PATCH] Fix new type error --- radicale/server.py | 9 +++++++-- radicale/tests/__init__.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/radicale/server.py b/radicale/server.py index 6cb4c7b4..62fe4ef3 100644 --- a/radicale/server.py +++ b/radicale/server.py @@ -58,11 +58,16 @@ elif sys.platform == "win32": # IPv4 (host, port) and IPv6 (host, port, flowinfo, scopeid) -ADDRESS_TYPE = Union[Tuple[str, int], Tuple[str, int, int, int]] +ADDRESS_TYPE = Union[Tuple[Union[str, bytes, bytearray], int], + Tuple[str, int, int, int]] def format_address(address: ADDRESS_TYPE) -> str: - return "[%s]:%d" % address[:2] + host, port, *_ = address + if not isinstance(host, str): + raise NotImplementedError("Unsupported address format: %r" % + (address,)) + return "[%s]:%d" % (host, port) class ParallelHTTPServer(socketserver.ThreadingMixIn, diff --git a/radicale/tests/__init__.py b/radicale/tests/__init__.py index 2e132560..fe8dbdef 100644 --- a/radicale/tests/__init__.py +++ b/radicale/tests/__init__.py @@ -137,8 +137,8 @@ class BaseTest: status, _, answer = self.request("GET", path, check=check, **kwargs) return status, answer - def post(self, path: str, data: str = None, check: Optional[int] = 200, - **kwargs) -> Tuple[int, str]: + def post(self, path: str, data: Optional[str] = None, + check: Optional[int] = 200, **kwargs) -> Tuple[int, str]: status, _, answer = self.request("POST", path, data, check=check, **kwargs) return status, answer