mirror of
https://github.com/9001/copyparty.git
synced 2025-08-16 08:32:13 -06:00
linter fixes
This commit is contained in:
parent
250c8c56f0
commit
3d245431fc
24
.vscode/settings.json
vendored
24
.vscode/settings.json
vendored
|
@ -22,6 +22,9 @@
|
||||||
"terminal.ansiBrightCyan": "#9cf0ed",
|
"terminal.ansiBrightCyan": "#9cf0ed",
|
||||||
"terminal.ansiBrightWhite": "#ffffff",
|
"terminal.ansiBrightWhite": "#ffffff",
|
||||||
},
|
},
|
||||||
|
"python.terminal.activateEnvironment": false,
|
||||||
|
"python.analysis.enablePytestSupport": false,
|
||||||
|
"python.analysis.typeCheckingMode": "standard",
|
||||||
"python.testing.pytestEnabled": false,
|
"python.testing.pytestEnabled": false,
|
||||||
"python.testing.unittestEnabled": true,
|
"python.testing.unittestEnabled": true,
|
||||||
"python.testing.unittestArgs": [
|
"python.testing.unittestArgs": [
|
||||||
|
@ -31,23 +34,8 @@
|
||||||
"-p",
|
"-p",
|
||||||
"test_*.py"
|
"test_*.py"
|
||||||
],
|
],
|
||||||
"python.linting.pylintEnabled": 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')
|
||||||
"python.linting.flake8Enabled": true,
|
"editor.formatOnSave": false,
|
||||||
"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,
|
|
||||||
"[html]": {
|
"[html]": {
|
||||||
"editor.formatOnSave": false,
|
"editor.formatOnSave": false,
|
||||||
"editor.autoIndent": "keep",
|
"editor.autoIndent": "keep",
|
||||||
|
@ -58,6 +46,4 @@
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.makefile": "makefile"
|
"*.makefile": "makefile"
|
||||||
},
|
},
|
||||||
"python.linting.enabled": true,
|
|
||||||
"python.pythonPath": "/usr/bin/python3"
|
|
||||||
}
|
}
|
|
@ -68,7 +68,7 @@ if True: # pylint: disable=using-constant-test
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if os.environ.get("PRTY_NO_TLS"):
|
if os.environ.get("PRTY_NO_TLS"):
|
||||||
|
@ -350,7 +350,7 @@ def configure_ssl_ver(al: argparse.Namespace) -> None:
|
||||||
# oh man i love openssl
|
# oh man i love openssl
|
||||||
# check this out
|
# check this out
|
||||||
# hold my beer
|
# hold my beer
|
||||||
assert ssl
|
assert ssl # type: ignore
|
||||||
ptn = re.compile(r"^OP_NO_(TLS|SSL)v")
|
ptn = re.compile(r"^OP_NO_(TLS|SSL)v")
|
||||||
sslver = terse_sslver(al.ssl_ver).split(",")
|
sslver = terse_sslver(al.ssl_ver).split(",")
|
||||||
flags = [k for k in ssl.__dict__ if ptn.match(k)]
|
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:
|
def configure_ssl_ciphers(al: argparse.Namespace) -> None:
|
||||||
assert ssl
|
assert ssl # type: ignore
|
||||||
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
||||||
if al.ssl_ver:
|
if al.ssl_ver:
|
||||||
ctx.options &= ~al.ssl_flags_en
|
ctx.options &= ~al.ssl_flags_en
|
||||||
|
|
|
@ -57,7 +57,7 @@ if TYPE_CHECKING:
|
||||||
# Mflags: TypeAlias = dict[str, Vflags]
|
# Mflags: TypeAlias = dict[str, Vflags]
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
LEELOO_DALLAS = "leeloo_dallas"
|
LEELOO_DALLAS = "leeloo_dallas"
|
||||||
|
|
|
@ -42,7 +42,7 @@ if True: # pylint: disable=using-constant-test
|
||||||
from typing import Any, Optional, Union
|
from typing import Any, Optional, Union
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class FSE(FilesystemError):
|
class FSE(FilesystemError):
|
||||||
|
|
|
@ -85,7 +85,7 @@ if True: # pylint: disable=using-constant-test
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class HttpSrv(object):
|
class HttpSrv(object):
|
||||||
|
|
|
@ -74,7 +74,7 @@ class Ico(object):
|
||||||
try:
|
try:
|
||||||
_, _, tw, th = pb.textbbox((0, 0), ext)
|
_, _, tw, th = pb.textbbox((0, 0), ext)
|
||||||
except:
|
except:
|
||||||
tw, th = pb.textsize(ext)
|
tw, th = pb.textsize(ext) # type: ignore
|
||||||
|
|
||||||
tw += len(ext)
|
tw += len(ext)
|
||||||
cw = tw // len(ext)
|
cw = tw // len(ext)
|
||||||
|
|
|
@ -581,7 +581,7 @@ class MTag(object):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if k == ".aq":
|
if k == ".aq":
|
||||||
v /= 1000
|
v /= 1000 # type: ignore
|
||||||
|
|
||||||
if k == "ac" and v.startswith("mp4a.40."):
|
if k == "ac" and v.startswith("mp4a.40."):
|
||||||
v = "aac"
|
v = "aac"
|
||||||
|
|
|
@ -66,7 +66,7 @@ if TYPE_CHECKING:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class SvcHub(object):
|
class SvcHub(object):
|
||||||
|
|
|
@ -45,7 +45,7 @@ if TYPE_CHECKING:
|
||||||
from .svchub import SvcHub
|
from .svchub import SvcHub
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
lg = logging.getLogger("tftp")
|
lg = logging.getLogger("tftp")
|
||||||
|
|
|
@ -39,7 +39,7 @@ if TYPE_CHECKING:
|
||||||
from .svchub import SvcHub
|
from .svchub import SvcHub
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
HAVE_PIL = False
|
HAVE_PIL = False
|
||||||
HAVE_PILF = False
|
HAVE_PILF = False
|
||||||
|
|
|
@ -39,7 +39,7 @@ if TYPE_CHECKING:
|
||||||
from .httpsrv import HttpSrv
|
from .httpsrv import HttpSrv
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class U2idx(object):
|
class U2idx(object):
|
||||||
|
|
|
@ -3015,7 +3015,7 @@ class Up2k(object):
|
||||||
|
|
||||||
def handle_chunks(
|
def handle_chunks(
|
||||||
self, ptop: str, wark: str, chashes: list[str]
|
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:
|
with self.mutex, self.reg_mutex:
|
||||||
self.db_act = self.vol_act[ptop] = time.time()
|
self.db_act = self.vol_act[ptop] = time.time()
|
||||||
job = self.registry[ptop].get(wark)
|
job = self.registry[ptop].get(wark)
|
||||||
|
@ -3037,6 +3037,7 @@ class Up2k(object):
|
||||||
t = "that chunk is already being written to:\n {}\n {} {}/{}\n {}"
|
t = "that chunk is already being written to:\n {}\n {} {}/{}\n {}"
|
||||||
raise Pebkac(400, t.format(wark, chash, idx, nh, job["name"]))
|
raise Pebkac(400, t.format(wark, chash, idx, nh, job["name"]))
|
||||||
|
|
||||||
|
assert chash # type: ignore
|
||||||
chunksize = up2k_chunksize(job["size"])
|
chunksize = up2k_chunksize(job["size"])
|
||||||
|
|
||||||
coffsets = []
|
coffsets = []
|
||||||
|
|
|
@ -60,7 +60,7 @@ except:
|
||||||
|
|
||||||
|
|
||||||
if PY2:
|
if PY2:
|
||||||
range = xrange
|
range = xrange # type: ignore
|
||||||
|
|
||||||
|
|
||||||
if sys.version_info >= (3, 7) or (
|
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}
|
c = self.c = {k: v for k, v in self.c.items() if now - v < self.maxage}
|
||||||
try:
|
try:
|
||||||
self.oldest = c[min(c, key=c.get)]
|
self.oldest = c[min(c, key=c.get)] # type: ignore
|
||||||
except:
|
except:
|
||||||
self.oldest = now
|
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"
|
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()
|
# gmtime ~= datetime.fromtimestamp(ts, UTC).timetuple()
|
||||||
y, mo, d, h, mi, s, wd, _, _ = time.gmtime(ts)
|
y, mo, d, h, mi, s, wd, _, _ = time.gmtime(ts)
|
||||||
return RFC2822 % (WKDAYS[wd], d, MONTHS[mo - 1], y, h, mi, s)
|
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"""
|
"""url quoter which deals with bytes correctly"""
|
||||||
btxt = w8enc(txt)
|
btxt = w8enc(txt)
|
||||||
quot = quote(btxt, safe=b"/")
|
quot = quote(btxt, safe=b"/")
|
||||||
return w8dec(quot.replace(b" ", b"+"))
|
return w8dec(quot.replace(b" ", b"+")) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
def _quotep3(txt: str) -> str:
|
def _quotep3(txt: str) -> str:
|
||||||
|
|
Loading…
Reference in a new issue