Răsfoiți Sursa

Fix new type error

Unrud 3 ani în urmă
părinte
comite
f8e28f6b6e
2 a modificat fișierele cu 9 adăugiri și 4 ștergeri
  1. 7 2
      radicale/server.py
  2. 2 2
      radicale/tests/__init__.py

+ 7 - 2
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,

+ 2 - 2
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