From 8c1869d9d9d0fa315152cee9461860d07bb2816c Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Sun, 28 Jan 2024 21:49:06 +0100 Subject: [PATCH] REFACTOR: improve type annotations --- FabLabKasse/shopping/backend/legacy_offline_kassenbuch.py | 3 ++- FabLabKasse/test_kassenbuch.py | 4 ++-- FabLabKasse/tools/dummy-printserver.py | 4 ++-- install_debian.sh | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/FabLabKasse/shopping/backend/legacy_offline_kassenbuch.py b/FabLabKasse/shopping/backend/legacy_offline_kassenbuch.py index 9b209dc..770f200 100755 --- a/FabLabKasse/shopping/backend/legacy_offline_kassenbuch.py +++ b/FabLabKasse/shopping/backend/legacy_offline_kassenbuch.py @@ -38,6 +38,7 @@ import logging import contextlib # for "caching" the json import os +from typing import Tuple def load_json_from_url(url): @@ -78,7 +79,7 @@ def download_with_fallback(url): yield f -def load_categories_from_web(cfg) -> (list[Category], int): +def load_categories_from_web(cfg) -> Tuple[list[Category], int]: """ Download and parse list of categories diff --git a/FabLabKasse/test_kassenbuch.py b/FabLabKasse/test_kassenbuch.py index e274944..471b9dc 100755 --- a/FabLabKasse/test_kassenbuch.py +++ b/FabLabKasse/test_kassenbuch.py @@ -100,8 +100,8 @@ def call_kb(command: str) -> str: path_to_here + "/kassenbuch.py", "--ensure-dummy-db", ] + command.split(" ") - cmd = [x.encode("UTF-8") for x in cmd] - result = subprocess.run(cmd, encoding="UTF-8", capture_output=True) + cmd_bytes = [x.encode("UTF-8") for x in cmd] + result = subprocess.run(cmd_bytes, encoding="UTF-8", capture_output=True) self.assertEqual(result.returncode, 0, "Command failed: " + repr(result)) return result.stdout diff --git a/FabLabKasse/tools/dummy-printserver.py b/FabLabKasse/tools/dummy-printserver.py index abf9239..661d576 100755 --- a/FabLabKasse/tools/dummy-printserver.py +++ b/FabLabKasse/tools/dummy-printserver.py @@ -28,6 +28,6 @@ if not data: print("\n\n========= client disconnected =======\n\n") break - data = data.decode("ascii", errors="replace") - sys.stdout.write(data) + data_decoded = data.decode("ascii", errors="replace") + sys.stdout.write(data_decoded) sys.stdout.flush() diff --git a/install_debian.sh b/install_debian.sh index e74a5d0..a874095 100755 --- a/install_debian.sh +++ b/install_debian.sh @@ -44,7 +44,7 @@ sudo apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get -y install git # Python3 stuff sudo DEBIAN_FRONTEND=noninteractive apt-get -y install python3-pip python3 python3-dateutil python3-lxml python3-termcolor python3-serial python3-qrcode python3-docopt python3-requests python3-simplejson python3-sphinx -sudo DEBIAN_FRONTEND=noninteractive apt-get -y install python3-qtpy python3-pyqt5 pyqt5-dev-tools +sudo DEBIAN_FRONTEND=noninteractive apt-get -y install python3-qtpy python3-pyqt5 pyqt5-dev-tools mypy sudo python3 -m pip install -r requirements.txt # Dependencies only for Testing / Vagrant automation (dummy printserver / dummy FAUCard device) sudo DEBIAN_FRONTEND=noninteractive apt-get -y install psmisc socat