linter fixes

This commit is contained in:
ed 2024-08-05 18:48:16 +00:00
parent 250c8c56f0
commit 3d245431fc
13 changed files with 23 additions and 36 deletions

24
.vscode/settings.json vendored
View file

@ -22,6 +22,9 @@
"terminal.ansiBrightCyan": "#9cf0ed",
"terminal.ansiBrightWhite": "#ffffff",
},
"python.terminal.activateEnvironment": false,
"python.analysis.enablePytestSupport": false,
"python.analysis.typeCheckingMode": "standard",
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"python.testing.unittestArgs": [
@ -31,23 +34,8 @@
"-p",
"test_*.py"
],
"python.linting.pylintEnabled": true,
"python.linting.flake8Enabled": true,
"python.linting.banditEnabled": true,
"python.linting.mypyEnabled": true,
"python.linting.flake8Args": [
"--max-line-length=120",
"--ignore=E722,F405,E203,W503,W293,E402,E501,E128,E226",
],
"python.linting.banditArgs": [
"--ignore=B104,B110,B112"
],
// python3 -m isort --py=27 --profile=black copyparty/
"python.formatting.provider": "none",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.formatOnSave": true,
// python3 -m isort --py=27 --profile=black ~/dev/copyparty/{copyparty,tests}/*.py && python3 -m black -t py27 ~/dev/copyparty/{copyparty,tests,bin}/*.py $(find ~/dev/copyparty/copyparty/stolen -iname '*.py')
"editor.formatOnSave": false,
"[html]": {
"editor.formatOnSave": false,
"editor.autoIndent": "keep",
@ -58,6 +46,4 @@
"files.associations": {
"*.makefile": "makefile"
},
"python.linting.enabled": true,
"python.pythonPath": "/usr/bin/python3"
}

View file

@ -68,7 +68,7 @@ if True: # pylint: disable=using-constant-test
from typing import Any, Optional
if PY2:
range = xrange
range = xrange # type: ignore
try:
if os.environ.get("PRTY_NO_TLS"):
@ -350,7 +350,7 @@ def configure_ssl_ver(al: argparse.Namespace) -> None:
# oh man i love openssl
# check this out
# hold my beer
assert ssl
assert ssl # type: ignore
ptn = re.compile(r"^OP_NO_(TLS|SSL)v")
sslver = terse_sslver(al.ssl_ver).split(",")
flags = [k for k in ssl.__dict__ if ptn.match(k)]
@ -384,7 +384,7 @@ def configure_ssl_ver(al: argparse.Namespace) -> None:
def configure_ssl_ciphers(al: argparse.Namespace) -> None:
assert ssl
assert ssl # type: ignore
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
if al.ssl_ver:
ctx.options &= ~al.ssl_flags_en

View file

@ -57,7 +57,7 @@ if TYPE_CHECKING:
# Mflags: TypeAlias = dict[str, Vflags]
if PY2:
range = xrange
range = xrange # type: ignore
LEELOO_DALLAS = "leeloo_dallas"

View file

@ -42,7 +42,7 @@ if True: # pylint: disable=using-constant-test
from typing import Any, Optional, Union
if PY2:
range = xrange
range = xrange # type: ignore
class FSE(FilesystemError):

View file

@ -85,7 +85,7 @@ if True: # pylint: disable=using-constant-test
from typing import Any, Optional
if PY2:
range = xrange
range = xrange # type: ignore
class HttpSrv(object):

View file

@ -74,7 +74,7 @@ class Ico(object):
try:
_, _, tw, th = pb.textbbox((0, 0), ext)
except:
tw, th = pb.textsize(ext)
tw, th = pb.textsize(ext) # type: ignore
tw += len(ext)
cw = tw // len(ext)

View file

@ -581,7 +581,7 @@ class MTag(object):
continue
if k == ".aq":
v /= 1000
v /= 1000 # type: ignore
if k == "ac" and v.startswith("mp4a.40."):
v = "aac"

View file

@ -66,7 +66,7 @@ if TYPE_CHECKING:
pass
if PY2:
range = xrange
range = xrange # type: ignore
class SvcHub(object):

View file

@ -45,7 +45,7 @@ if TYPE_CHECKING:
from .svchub import SvcHub
if PY2:
range = xrange
range = xrange # type: ignore
lg = logging.getLogger("tftp")

View file

@ -39,7 +39,7 @@ if TYPE_CHECKING:
from .svchub import SvcHub
if PY2:
range = xrange
range = xrange # type: ignore
HAVE_PIL = False
HAVE_PILF = False

View file

@ -39,7 +39,7 @@ if TYPE_CHECKING:
from .httpsrv import HttpSrv
if PY2:
range = xrange
range = xrange # type: ignore
class U2idx(object):

View file

@ -3015,7 +3015,7 @@ class Up2k(object):
def handle_chunks(
self, ptop: str, wark: str, chashes: list[str]
) -> tuple[list[int], list[list[int]], str, float, bool]:
) -> tuple[int, list[list[int]], str, float, bool]:
with self.mutex, self.reg_mutex:
self.db_act = self.vol_act[ptop] = time.time()
job = self.registry[ptop].get(wark)
@ -3037,6 +3037,7 @@ class Up2k(object):
t = "that chunk is already being written to:\n {}\n {} {}/{}\n {}"
raise Pebkac(400, t.format(wark, chash, idx, nh, job["name"]))
assert chash # type: ignore
chunksize = up2k_chunksize(job["size"])
coffsets = []

View file

@ -60,7 +60,7 @@ except:
if PY2:
range = xrange
range = xrange # type: ignore
if sys.version_info >= (3, 7) or (
@ -809,7 +809,7 @@ class CachedSet(object):
c = self.c = {k: v for k, v in self.c.items() if now - v < self.maxage}
try:
self.oldest = c[min(c, key=c.get)]
self.oldest = c[min(c, key=c.get)] # type: ignore
except:
self.oldest = now
@ -1841,7 +1841,7 @@ MONTHS = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split()
RFC2822 = "%s, %02d %s %04d %02d:%02d:%02d GMT"
def formatdate(ts: Optional[int] = None) -> str:
def formatdate(ts: Optional[float] = None) -> str:
# gmtime ~= datetime.fromtimestamp(ts, UTC).timetuple()
y, mo, d, h, mi, s, wd, _, _ = time.gmtime(ts)
return RFC2822 % (WKDAYS[wd], d, MONTHS[mo - 1], y, h, mi, s)
@ -2073,7 +2073,7 @@ def _quotep2(txt: str) -> str:
"""url quoter which deals with bytes correctly"""
btxt = w8enc(txt)
quot = quote(btxt, safe=b"/")
return w8dec(quot.replace(b" ", b"+"))
return w8dec(quot.replace(b" ", b"+")) # type: ignore
def _quotep3(txt: str) -> str: