diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 4fa6f914..27da2721 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -1783,6 +1783,7 @@ class HttpCli(object): open_ka["fun"] = gzip.GzipFile open_a = ["wb", lv[alg], None, 0x5FEE6600] # 2021-01-01 elif alg == "xz": + assert lzma # type: ignore # !rm open_ka = {"fun": lzma.open, "preset": lv[alg]} open_a = ["wb"] else: @@ -4128,6 +4129,8 @@ class HttpCli(object): "dbwt": None, } + assert vstate and vs # type: ignore # !rm + fmt = self.uparam.get("ls", "") if not fmt and (self.ua.startswith("curl/") or self.ua.startswith("fetch")): fmt = "v" diff --git a/copyparty/httpconn.py b/copyparty/httpconn.py index 09366742..1d76001e 100644 --- a/copyparty/httpconn.py +++ b/copyparty/httpconn.py @@ -162,6 +162,7 @@ class HttpConn(object): self.log_src = self.log_src.replace("[36m", "[35m") try: + assert ssl # type: ignore # !rm ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH) ctx.load_cert_chain(self.args.cert) if self.args.ssl_ver: diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index bdec07c5..f89523fb 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -157,6 +157,7 @@ class HttpSrv(object): self.u2idx_free: dict[str, U2idx] = {} self.u2idx_n = 0 + assert jinja2 # type: ignore # !rm env = jinja2.Environment() env.loader = jinja2.FunctionLoader(lambda f: load_jinja2_resource(self.E, f)) jn = [ diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 483e4e6e..c65ffab2 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -53,6 +53,8 @@ class U2idx(object): self.log("your python does not have sqlite3; searching will be disabled") return + assert sqlite3 # type: ignore # !rm + self.active_id = "" self.active_cur: Optional["sqlite3.Cursor"] = None self.cur: dict[str, "sqlite3.Cursor"] = {} diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 7d5c6e62..0f87b4e8 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -176,6 +176,7 @@ class Up2k(object): self.spools: set[tempfile.SpooledTemporaryFile[bytes]] = set() if HAVE_SQLITE3: # mojibake detector + assert sqlite3 # type: ignore # !rm self.mem_cur = self._orz(":memory:") self.mem_cur.execute(r"create table a (b text)") self.sqlite_ver = tuple([int(x) for x in sqlite3.sqlite_version.split(".")]) @@ -2477,6 +2478,7 @@ class Up2k(object): raise Exception("%s\n%s\n%s" % (t, txt, t)) def _orz(self, db_path: str) -> "sqlite3.Cursor": + assert sqlite3 # type: ignore # !rm c = sqlite3.connect( db_path, timeout=self.timeout, check_same_thread=False ).cursor() @@ -2539,6 +2541,7 @@ class Up2k(object): def _backup_db( self, db_path: str, cur: "sqlite3.Cursor", ver: Optional[int], msg: str ) -> "sqlite3.Cursor": + assert sqlite3 # type: ignore # !rm bak = "{}.bak.{:x}.v{}".format(db_path, int(time.time()), ver) self.log(msg + bak) try: diff --git a/copyparty/util.py b/copyparty/util.py index aa00d693..08f78a66 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -134,7 +134,7 @@ if True: # pylint: disable=using-constant-test from collections.abc import Callable, Iterable import typing - from typing import Any, Generator, IO, Optional, Pattern, Protocol, Union + from typing import IO, Any, Generator, Optional, Pattern, Protocol, Union try: from typing import LiteralString