diff --git a/.vscode/settings.json b/.vscode/settings.json index c746d779..2608f2c7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } \ No newline at end of file diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 7ce49e37..bdd41baa 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -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 diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index 0965103e..4932404b 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -57,7 +57,7 @@ if TYPE_CHECKING: # Mflags: TypeAlias = dict[str, Vflags] if PY2: - range = xrange + range = xrange # type: ignore LEELOO_DALLAS = "leeloo_dallas" diff --git a/copyparty/ftpd.py b/copyparty/ftpd.py index d034190a..7137e0ad 100644 --- a/copyparty/ftpd.py +++ b/copyparty/ftpd.py @@ -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): diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index 9d28e374..6ee56f87 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -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): diff --git a/copyparty/ico.py b/copyparty/ico.py index 9788a0b6..c149397d 100644 --- a/copyparty/ico.py +++ b/copyparty/ico.py @@ -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) diff --git a/copyparty/mtag.py b/copyparty/mtag.py index c1a1a4f4..bf2719ad 100644 --- a/copyparty/mtag.py +++ b/copyparty/mtag.py @@ -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" diff --git a/copyparty/svchub.py b/copyparty/svchub.py index 21581a7d..e0082d9a 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -66,7 +66,7 @@ if TYPE_CHECKING: pass if PY2: - range = xrange + range = xrange # type: ignore class SvcHub(object): diff --git a/copyparty/tftpd.py b/copyparty/tftpd.py index 5e0fea30..1da648e5 100644 --- a/copyparty/tftpd.py +++ b/copyparty/tftpd.py @@ -45,7 +45,7 @@ if TYPE_CHECKING: from .svchub import SvcHub if PY2: - range = xrange + range = xrange # type: ignore lg = logging.getLogger("tftp") diff --git a/copyparty/th_srv.py b/copyparty/th_srv.py index 51e6f2e9..b36e9763 100644 --- a/copyparty/th_srv.py +++ b/copyparty/th_srv.py @@ -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 diff --git a/copyparty/u2idx.py b/copyparty/u2idx.py index 2e340da6..24ad7e38 100644 --- a/copyparty/u2idx.py +++ b/copyparty/u2idx.py @@ -39,7 +39,7 @@ if TYPE_CHECKING: from .httpsrv import HttpSrv if PY2: - range = xrange + range = xrange # type: ignore class U2idx(object): diff --git a/copyparty/up2k.py b/copyparty/up2k.py index cfaced32..15ca799c 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -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 = [] diff --git a/copyparty/util.py b/copyparty/util.py index 89de4430..1ea3cd03 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -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: