From f0ad35c2f96486d4948361c40ef9602ed811391c Mon Sep 17 00:00:00 2001 From: BDisp Date: Wed, 1 Oct 2025 00:09:32 +0100 Subject: [PATCH 1/2] Add CI workflow and configuration files --- .github/workflows/python-lint.yml | 23 +++++++++++++++++++++++ pyrightconfig.json | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/python-lint.yml create mode 100644 pyrightconfig.json diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml new file mode 100644 index 0000000..cadaceb --- /dev/null +++ b/.github/workflows/python-lint.yml @@ -0,0 +1,23 @@ +name: Python Lint + +on: + push: + pull_request: + +jobs: + pyright: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Node.js (for pyright) + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install pyright + run: npm install -g pyright + + - name: Run pyright + run: pyright diff --git a/pyrightconfig.json b/pyrightconfig.json new file mode 100644 index 0000000..86d24ba --- /dev/null +++ b/pyrightconfig.json @@ -0,0 +1,19 @@ +{ + // Assume Windows environment so winreg and other Windows-only modules are available + "pythonPlatform": "Windows", + + // Point to your source if not at repo root (optional) + "include": [ "." ], + + // Match Pylance defaults (what VS 2022 is showing you) + "typeCheckingMode": "basic", + + // Keep useful checks + "reportUnboundVariable": "error", + "reportAttributeAccessIssue": "error", + "reportWildcardImportFromLibrary": "warning", + + // Disable overly strict stuff you don�t want in CI + "reportMissingImports": "none", + "reportMissingModuleSource": "none" +} From eab60bcf6c613951583b49db8a547e5d6783c246 Mon Sep 17 00:00:00 2001 From: BDisp Date: Wed, 1 Oct 2025 00:15:38 +0100 Subject: [PATCH 2/2] Fix py errors and warnings --- gettools.py | 13 ++++--------- unlocker.py | 4 +--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/gettools.py b/gettools.py index 5c03b39..db4b0e9 100644 --- a/gettools.py +++ b/gettools.py @@ -31,11 +31,7 @@ import zipfile import time -# For Python 3.0 and later -import urllib -# noinspection PyCompatibility -from urllib.request import urlopen, Request, urlretrieve, install_opener -# noinspection PyCompatibility +from urllib.request import urlopen, build_opener, install_opener, Request, urlretrieve from html.parser import HTMLParser # Check minimal Python version is 3 @@ -69,11 +65,10 @@ def convertpath(path): return path.replace(os.path.sep, '/') def reporthook(count, block_size, total_size): - global start_time if count == 0: - start_time = time.time() + reporthook.start_time = time.time() return - duration = time.time() - start_time + duration = time.time() - reporthook.start_time progress_size = int(count * block_size) speed = int(progress_size / (1024 * duration)) if duration>0 else 0 percent = min(int(count*block_size*100/total_size),100) @@ -170,7 +165,7 @@ def DownloadAndExtractTarFile(url, dest): print('Retrieving Darwin tools from: ' + urlpost15) try: # Try to get tools from packages folder - opener = urllib.request.build_opener() + opener = build_opener() opener.addheaders = [('User-Agent','Magic Browser')] install_opener(opener) urlretrieve(urlpost15, convertpath(dest + '/tools/' + tarName), reporthook) diff --git a/unlocker.py b/unlocker.py index 35bc7d8..7509099 100644 --- a/unlocker.py +++ b/unlocker.py @@ -56,8 +56,7 @@ # Setup imports depending on whether IronPython or CPython if sys.platform == 'win32' \ or sys.platform == 'cli': - # noinspection PyUnresolvedReferences - from winreg import * + from winreg import ConnectRegistry, HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx @@ -343,7 +342,6 @@ def patchvmkctl(name): print('smcPresent Patched: ' + name) -# noinspection PyUnresolvedReferences def main(): # Work around absent Platform module on VMkernel if os.name == 'nt' or os.name == 'cli':