fix linter warnings

This commit is contained in:
ed 2024-09-20 22:24:39 +00:00
parent d866841c19
commit 58cf01c2ad
6 changed files with 11 additions and 1 deletions

View file

@ -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"

View file

@ -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:

View file

@ -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 = [

View file

@ -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"] = {}

View file

@ -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:

View file

@ -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