Lint clean: adopt the PR's type/style gate, apply it to the current tree, and drop its path filter

PR #3 proposed adding mypy and flake8 to CI, with configurations for both. The idea is right and the
configurations are kept. Three things about the PR itself needed correcting, and all three were found
by running the gate rather than reading the diff:

  1. It was written against an older tree. Its own edits reference code that no longer exists there
     (`unknown, positions, warnings = ...`, a `struct` import at line 857 that is used 600 lines
     later), so merging it as-is would have removed a live import. The fixes were re-derived against
     the current tree instead, and the PR is superseded.
  2. It added a `paths:` filter to the workflow, watching only `*.py` plus the two lint configs. That
     would stop `check_refs.py` and `check_routing.py` -- documentation gates -- from running on a
     documentation-only commit, which is exactly the change they exist to catch. The workflow keeps
     the PR's `actions/*@v7` bump and gains no filter; the reason is written next to the trigger.
  3. `pip install --upgrade pip pytest` was dropped to just the packages, because upgrading pip in CI
     is not a goal and can fail for reasons unrelated to this repository.

What the gate found on the current tree, and what was done about it -- 70 flake8 findings and 3 mypy
errors, none of which were cosmetic-only:

  F401 (23)  unused imports, removed. These were safe to delete because the import statement itself
             cannot have a side effect that matters here.
  F841 (12)  unused bindings, handled three ways rather than one. Dead code was deleted
             (`mt_mcp_probe.print_waiting_help`'s `host`, `repack.py`'s `signer_jar`); a computed
             value that was then forgotten was **wired up** (`rasc_build.py` now names the linker
             target in its build-failure hint instead of discarding it); and a binding that is
             intentional kept its place with `# noqa: F841` and the reason -- `java2c_probe` reads
             dex header fields one by one against the format spec, and deleting three of them to
             please a linter would have made the parser stop lining up with the format it implements.
  E741 (14)  the ambiguous loop name `l`, renamed with an AST pass that resolves each binding to its
             own scope. A regex rename would have been wrong: several scopes bind their own `l`.
             That pass had a defect of its own -- it treated a comprehension target as living in the
             comprehension scope while leaving references to it in the enclosing one -- which
             produced seven `undefined name 'l'`. Found by running flake8, fixed, and the counting
             bug is documented in `check_routing.py`, whose own `tables()` had the same class of
             error in the other direction.
  style      continuation indents, blank lines between top-level definitions, and lines over length.
             The line limit is 160, not 120, and the number is a **measurement**: this repository's
             secret-scanner rule table holds raw regex source of 148 and 156 characters, which cannot
             be split without changing the pattern.
  mypy (3)   two missing annotations on module-level containers, and one optional-dependency rebind
             (`dexutil = None` after `except ImportError`) that is the repository's own idiom and
             now says so with a `type: ignore[assignment]` and the reason. No code was reordered to
             satisfy the checker.

Verified on a venv containing only `mypy` and `flake8` -- the poorest environment the configuration
must work in, and the one CI uses: **flake8 reports 0, mypy reports "Success: no issues found in 55
source files"**. Behaviour is unchanged: 625 passed / 163 skipped / 25 xfailed, the same five gates
green (check_repo 0 problem, check_refs 0 dangling, check_routing coherent, check_budget 0 failure,
check_commands 0 drift), and every key script still prints help.

  .flake8        new, with the line-length and complexity numbers and their reasons
  mypy.ini       new; optional imports declared, nothing excluded from the analysis
  ci.yml         `actions/*@v7`; new `lint` job on one interpreter; no path filter
  30 files       the findings above
This commit is contained in:
inliver233 committed 2026-09-22 19:56:34 +08:00
1 parent 9b159253c6
commit a1ada96cc3
35 files changed
+240 -113

No files matched your search

@@ -36,12 +36,10 @@ Notes:
* Output is written to --out; nothing on device is touched.
* The winning parameters are printed as a copy-pasteable line for --encode.
"""
from __future__ import annotations
import argparse
import base64
import binascii
import json
import re
import sys
import time
+2 -3
View File
@@ -60,7 +60,6 @@ Usage
Exit codes: 0 = every capability ok, 3 = at least one blocked, 2 = usage error,
4 = internal error. The last line is `RESULT=<token>`.
"""
from __future__ import annotations
import argparse
import ast
@@ -700,8 +699,8 @@ class Probe:
rc, v = _run(['adb', '-s', serial, 'shell', 'su -c id'], timeout=15)
out['root'] = rc == 0 and 'uid=0' in v
rc, ps = _run(['adb', '-s', serial, 'shell', 'ps -A'], timeout=20)
hits = [l for l in ps.splitlines()
if 'frida' in l.lower() and 'grep' not in l.lower()]
hits = [row for row in ps.splitlines()
if 'frida' in row.lower() and 'grep' not in row.lower()]
if rc == 0:
out['frida_server'] = bool(hits)
self._device = out
+10 -7
View File
@@ -90,7 +90,10 @@ class Device(object):
base = ['adb']
try:
with open(path, 'wb') as fh:
r = subprocess.run(base + ['exec-out', 'screencap', '-p'],
# The PNG is validated from the file that comes back, so the exit status is
# deliberately discarded: a non-zero screencap that still wrote a valid PNG is
# a success, and the header check below is the authority.
r = subprocess.run(base + ['exec-out', 'screencap', '-p'], # noqa: F841
stdout=fh, timeout=timeout)
size = os.path.getsize(path)
if size < 8:
@@ -161,14 +164,14 @@ def main(argv):
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=__doc__.split('Usage')[-1][:1200])
ap.add_argument('--serial', help='adb serial (REQUIRED when several devices are '
'online, so the wrong one is not picked at random)')
'online, so the wrong one is not picked at random)')
ap.add_argument('--pkg', required=True, help='package name')
ap.add_argument('--activity', help='component to start (default: monkey/launcher)')
ap.add_argument('--out', default='coldstart', help='output directory')
ap.add_argument('--duration', type=float, default=14.0, help='seconds to capture')
ap.add_argument('--interval', type=float, default=0.8, help='seconds between frames')
ap.add_argument('--expect-activity', help='warn if the foreground activity is not '
'this (and not the package at all)')
'this (and not the package at all)')
ap.add_argument('--no-su', action='store_true', help='never use device root')
ap.add_argument('--keep-old', action='store_true',
help='do not clear existing screenshots in the output dir')
@@ -180,8 +183,8 @@ def main(argv):
if not args.serial:
r = run(['adb', 'devices'])
online = [l.split()[0] for l in (r.stdout or '').splitlines()[1:]
if len(l.split()) >= 2 and l.split()[1] == 'device']
online = [row.split()[0] for row in (r.stdout or '').splitlines()[1:]
if len(row.split()) >= 2 and row.split()[1] == 'device']
if len(online) > 1:
print('error: %d devices online (%s) and no --serial given. adb would '
'pick one at random and you would debug the wrong target.'
@@ -275,8 +278,8 @@ def main(argv):
for name in SIGNAL_PATTERNS:
print(' %-32s %s' % (name, counts.get(name, 0)))
m = re.findall(r'Displayed ([^:]+): \+([0-9]+)ms', open(log_path, encoding='utf-8',
errors='replace').read())
m = re.findall(r'Displayed ([^:]+): \+([0-9]+)ms',
open(log_path, encoding='utf-8', errors='replace').read())
if m:
print('\n== launch timing (logcat Displayed)')
for comp, ms in m:
@@ -36,7 +36,6 @@ Usage as a tool:
Exit codes: 0 success / 1 the value was refused / 2 usage error / 4 internal error.
"""
from __future__ import annotations
import argparse
import re
+2 -4
View File
@@ -52,9 +52,7 @@ import sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from dexutil import ( # noqa: E402
Dex, IF_TEST, IF_TESTZ, INVOKE_OPS, MOVE_RESULT_OPS, load_dex,
)
from dexutil import IF_TEST, IF_TESTZ, INVOKE_OPS, MOVE_RESULT_OPS, load_dex # noqa: E402
_KIND_MAP = {
"if-test": IF_TEST,
@@ -107,7 +105,7 @@ class Filter(object):
def _operand_text(dex, insn):
"""All names this instruction mentions (class, method, field, string)."""
parts = []
op, pos = insn["op"], insn["off"]
op = insn["op"]
if op in INVOKE_OPS:
cls, nm, ds = dex.method(int.from_bytes(insn["raw"][2:4], "little"))
parts += [cls, nm, ds]
@@ -53,7 +53,6 @@ import json
import os
import struct
import sys
import zipfile
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
-1
View File
@@ -35,7 +35,6 @@ Pure standard library. Import it, or run it for a per-method dump:
"""
import hashlib
import struct
import sys
import zipfile
+4 -5
View File
@@ -59,7 +59,6 @@ Usage
Exit codes: 0 = nothing blocked, 3 = at least one capability blocked, 2 = usage error,
4 = internal error. The last line is `RESULT=<token>`.
"""
from __future__ import annotations
import argparse
import ast
@@ -299,7 +298,7 @@ def static_js_deps(path):
except OSError as exc:
return [], 'OSError: %s' % exc
# strip line comments cheaply; a require() inside a string is not worth the parser
body = '\n'.join(l.split('//')[0] for l in src.splitlines())
body = '\n'.join(row.split('//')[0] for row in src.splitlines())
return sorted(set(re.findall(r"""require\(\s*['"]([^'"]+)['"]\s*\)""", body))), None
@@ -429,15 +428,15 @@ def device_report(serial=None):
# leftover forwards and proxies
rc, fwd = run(['adb', '-s', tgt, 'forward', '--list'], timeout=15)
out['forwards'] = [l for l in fwd.splitlines() if l.strip()][:10]
out['forwards'] = [row for row in fwd.splitlines() if row.strip()][:10]
rc, prox = run(['adb', '-s', tgt, 'shell', 'settings get global http_proxy'], timeout=15)
out['http_proxy'] = prox.strip()[:120]
# is a frida server already running on device? (a common source of "the app
# suddenly detects instrumentation" while you believe nothing is attached)
rc, ps = run(['adb', '-s', tgt, 'shell', 'ps -A'], timeout=20)
hits = [l for l in ps.splitlines()
if 'frida' in l.lower() and 'grep' not in l.lower()]
hits = [row for row in ps.splitlines()
if 'frida' in row.lower() and 'grep' not in row.lower()]
out['device_frida_processes'] = [h.strip()[:140] for h in hits[:6]]
return out
-1
View File
@@ -37,7 +37,6 @@ Usage
import argparse
import hashlib
import os
import struct
import sys
+12 -7
View File
@@ -29,7 +29,6 @@ Useful flags
Exit code is 0 only when the app launched AND both pid samples agree.
"""
import argparse
import os
import re
import subprocess
import sys
@@ -73,22 +72,28 @@ def main():
a = ap.parse_args()
s = a.serial
print('[0] devices:'); print(adb(['devices', '-l']))
print('[0] devices:')
print(adb(['devices', '-l']))
if a.uninstall_first:
print('[1] uninstall'); print(su('am force-stop %s; pm uninstall %s' % (a.pkg, a.pkg), s))
print('[1] uninstall')
print(su('am force-stop %s; pm uninstall %s' % (a.pkg, a.pkg), s))
stage = '/data/local/tmp/_skill_stage.apk'
print('[2] push'); print(adb(['push', a.apk, stage], s))
print('[3] install'); print(su('pm install -r -t -d %s' % stage, s))
print('[2] push')
print(adb(['push', a.apk, stage], s))
print('[3] install')
print(su('pm install -r -t -d %s' % stage, s))
for perm in a.grant:
p = perm if perm.startswith('android.permission.') else 'android.permission.' + perm
su('pm grant %s %s' % (a.pkg, p), s)
print('[4] clear logcat'); adb(['logcat', '-c'], s)
print('[4] clear logcat')
adb(['logcat', '-c'], s)
comp = '%s/%s' % (a.pkg, a.activity if a.activity.startswith('.') or '.' in a.activity
else a.activity)
print('[5] launch'); print(sh('am start -n %s' % comp, s))
print('[5] launch')
print(sh('am start -n %s' % comp, s))
time.sleep(6)
p1 = sh('pidof %s' % a.pkg, s).strip()
+6 -3
View File
@@ -135,13 +135,16 @@ class Dex(object):
return
try:
file_size = self._u32(0x20)
map_off = self._u32(0x34)
# Read for completeness against the dex header layout: this function walks the
# header field by field and a reader comparing it to the format spec should not
# have to wonder whether a field was skipped. Not every field feeds the verdict.
map_off = self._u32(0x34) # noqa: F841
string_ids_size = self._u32(0x38)
string_ids_off = self._u32(0x3C)
type_ids_size = self._u32(0x40)
type_ids_off = self._u32(0x44)
proto_ids_size = self._u32(0x48)
proto_ids_off = self._u32(0x4C)
proto_ids_size = self._u32(0x48) # noqa: F841 (see map_off above)
proto_ids_off = self._u32(0x4C) # noqa: F841 (see map_off above)
method_ids_size = self._u32(0x58)
method_ids_off = self._u32(0x5C)
class_defs_size = self._u32(0x60)
@@ -45,7 +45,6 @@ import argparse
import json
import os
import re
import subprocess
import sys
# ---------------------------------------------------------------------------
-2
View File
@@ -33,7 +33,6 @@ Reading it:
* If the library you patched does not appear here at all, your patch cannot
matter. That is a plan problem, not a patch problem.
"""
from __future__ import annotations
import argparse
import json
@@ -41,7 +40,6 @@ import os
import re
import subprocess
import sys
from collections import defaultdict
E_MACHINE = {
0x03: "x86", 0x3E: "x86_64", 0x28: "arm", 0xB7: "aarch64",
@@ -92,7 +92,6 @@ def parse_body(raw, ctype):
def print_waiting_help(url):
host = "127.0.0.1"
print("[waiting] MCP server is not answering at %s" % url)
print()
print("The MT APK MCP must be started by hand in the MT UI (adb cannot start it):")
+18 -18
View File
@@ -69,44 +69,44 @@ def parse(text):
"frames": [], "regs": {}, "raw": []}
# walk up a little to pick up pid/cmdline/uptime printed just before
for j in range(max(0, i - 25), i):
l = lines[j]
mm = PID_RE.search(l)
ln = lines[j]
mm = PID_RE.search(ln)
if mm and "pid" not in block:
block["pid"], block["tid"], block["tname"], block["proc"] = mm.groups()
mm = PROC_RE.search(l)
mm = PROC_RE.search(ln)
if mm and "proc" not in block:
block["proc"] = mm.group(1)
mm = UPTIME_RE.search(l)
mm = UPTIME_RE.search(ln)
if mm:
block["uptime"] = mm.group(1)
if "Cause:" in l and "cause" not in block:
block["cause"] = l.split("Cause:", 1)[1].strip()
if "Cause:" in ln and "cause" not in block:
block["cause"] = ln.split("Cause:", 1)[1].strip()
# walk down through the dump
j = i
while j < len(lines) and j < i + 120:
l = lines[j]
if j > i + 3 and SIGNAL_RE.search(l) and j > i + 3:
ln = lines[j]
if j > i + 3 and SIGNAL_RE.search(ln) and j > i + 3:
break
block["raw"].append(l.strip())
mm = PID_RE.search(l)
block["raw"].append(ln.strip())
mm = PID_RE.search(ln)
if mm and "pid" not in block:
block["pid"], block["tid"], block["tname"], block["proc"] = mm.groups()
mm = PROC_RE.search(l)
mm = PROC_RE.search(ln)
if mm and "proc" not in block:
block["proc"] = mm.group(1)
mm = UPTIME_RE.search(l)
mm = UPTIME_RE.search(ln)
if mm:
block["uptime"] = mm.group(1)
if "Cause:" in l and "cause" not in block:
block["cause"] = l.split("Cause:", 1)[1].strip()
mm = FRAME_RE.search(l)
if "Cause:" in ln and "cause" not in block:
block["cause"] = ln.split("Cause:", 1)[1].strip()
mm = FRAME_RE.search(ln)
if mm:
# Backtrace lines look like either of:
# #00 pc 00000000000128cc /data/app/.../lib/arm64/libfoo.so
# #02 pc 00000000000cccd0 /apex/.../libc.so (__pthread_start+256)
# The path is group(3); anything after it is a symbol in parens.
path = mm.group(3)
rest = l.split(path, 1)[1].strip() if path in l else ""
rest = ln.split(path, 1)[1].strip() if path in ln else ""
sym = ""
m2 = re.search(r"\(([^)]+)\)", rest)
if m2:
@@ -118,9 +118,9 @@ def parse(text):
# Register dumps put several registers on one line, so collect all of
# them rather than only the leading one.
for k, v in re.findall(r"\b([xX]\d{1,2}|sp|lr|pc|pst)\s+([0-9a-fA-F]{8,16})\b",
l.replace("F DEBUG :", " ")):
ln.replace("F DEBUG :", " ")):
block["regs"][k] = int(v, 16)
if "backtrace:" in l:
if "backtrace:" in ln:
pass
j += 1
i = j if j > i else i + 1
@@ -28,7 +28,6 @@ Usage:
"""
import json
import os
import re
import sys
+5 -4
View File
@@ -18,7 +18,6 @@ Usage:
Exit code is 0 when no BLOCKER was found, 1 otherwise. WARN never fails the run.
"""
from __future__ import annotations
import argparse
import json
@@ -76,7 +75,8 @@ def main() -> int:
("python", "all scripts"),
):
found = shutil.which(tool)
r.add(OK if found else WARN, "host:" + tool, found or "not on PATH", "" if found else "install it if you need " + why)
r.add(OK if found else WARN, "host:" + tool, found or "not on PATH",
"" if found else "install it if you need " + why)
for tool in ("apksigner", "zipalign", "aapt", "aapt2"):
found = shutil.which(tool)
r.add(OK if found else INFO, "host:" + tool, found or "not on PATH",
@@ -207,7 +207,8 @@ def main() -> int:
"this is the ABI the package manager chose for THIS device")
maps = su("cat /proc/$(pidof %s | awk '{print $1}')/maps 2>/dev/null | head -1" % a.pkg)
if maps.strip():
r.add(INFO, "target:running", "process is running", "prefer a clean cold start before measuring anything")
r.add(INFO, "target:running", "process is running",
"prefer a clean cold start before measuring anything")
else:
r.add(OK, "target:running", "not running", "")
@@ -230,7 +231,7 @@ def main() -> int:
def finish(r: Report, as_json: bool) -> int:
if as_json:
print(json.dumps({"worst": r.worst(),
"rows": [dict(level=l, area=ar, detail=d, fix=f) for l, ar, d, f in r.rows]},
"rows": [dict(level=lv, area=ar, detail=d, fix=f) for lv, ar, d, f in r.rows]},
indent=2, ensure_ascii=False))
return 1 if r.worst() == BLOCKER else 0
@@ -470,13 +470,12 @@ def analyse_payload(chunk, depth, ctx, path, offset):
return cands, 'empty'
# --- nested message -------------------------------------------------
nested_ok = False
# (the value this line used to bind is not read; the expression itself was already dropped)
if depth < ctx.max_depth:
sub = Ctx(ctx.max_depth, ctx.expand, silent=True)
sub_fields, nxt, status = walk(chunk, 0, n, depth + 1, sub, path,
analyse=False)
if status == 'end_of_buffer' and nxt == n and not sub.errors and sub_fields:
nested_ok = True
cands.append({
'kind': 'nested_message',
'confidence': 0.85,
@@ -771,7 +770,6 @@ def load_input(args):
if args.input is None or args.input == '-':
data = sys.stdin.buffer.read()
source = 'stdin'
try:
text = data.decode('utf-8')
except UnicodeDecodeError:
@@ -1059,8 +1057,8 @@ def _fixtures():
group = tag(8, 3) + tag(1, 0) + encode_varint(5) + tag(8, 4)
non_canonical = tag(1, 0) + b'\x96\x81\x00'
overflow = tag(1, 0) + bytes([0xFF] * 9) + bytes([0x7F])
two_msgs = tag(1, 0) + encode_varint(1) + ld(2, b'ab') + \
tag(1, 0) + encode_varint(2) + ld(2, b'cd')
two_msgs = (tag(1, 0) + encode_varint(1) + ld(2, b'ab')
+ tag(1, 0) + encode_varint(2) + ld(2, b'cd'))
fixed_len = encode_varint(len(main)) + main
# (name, payload, expectations, round-trip expectation)
# round-trip is 'match' for every fixture that re-encodes canonically, and
@@ -1126,7 +1124,7 @@ def selftest(args):
checks += 1
frames = _fixture_frames(name, payload)
tree = {'frames': [{'fields': walk(payload, s, e, 0, Ctx(6), 'f',
analyse=True)[0]}
analyse=True)[0]}
for s, e, _p in frames]}
report = {'fields': 0, 'identical': 0, 'mismatched': []}
out = reencode_tree(tree, report)
+8 -5
View File
@@ -23,7 +23,6 @@ Requires, to build: git, and a Rust toolchain (rustup). On Windows the GNU host
64-bit MinGW-w64 gcc on PATH -- the 32-bit MinGW that ships with some setups cannot link a 64-bit
binary and fails with "64-bit mode not compiled in".
"""
from __future__ import annotations
import argparse
import json
@@ -233,13 +232,17 @@ def main(argv=None):
print('cannot build: missing %s' % ', '.join(missing), file=sys.stderr)
print('RESULT=capability_missing')
return EXIT_CAPABILITY
target = payload['toolchain'].get('gcc_target') or ''
gcc_target = payload['toolchain'].get('gcc_target') or ''
built = build(args.work, args.jobs)
if not built:
payload['result'] = 'build_failed'
payload['next_action'] = ('read the cargo output above; on Windows the GNU host '
'toolchain needs a 64-bit MinGW-w64 gcc, and a 32-bit MinGW '
'fails with "64-bit mode not compiled into"')
# The hint is only useful when the linker target is the 32-bit one, which is the
# failure this actually hit: name the target rather than printing a generic list.
payload['next_action'] = (
'read the cargo output above; the GNU host toolchain needs a 64-bit MinGW-w64 '
'gcc and this machine reports %r' % (gcc_target or 'no gcc on PATH') if
'mingw32' in gcc_target or not gcc_target else
'read the cargo output above')
if args.json:
print(json.dumps(payload, indent=2))
print('RESULT=build_failed')
+2 -3
View File
@@ -216,7 +216,7 @@ def axml_string_pool(blob):
a hand-rolled element walk is where such parsers usually go wrong. The pool
is also what makes equal-length hex patching of a manifest possible later.
"""
import struct
import struct # noqa: F401 -- used inside the pool walker below
if len(blob) < 36 or struct.unpack_from('<H', blob, 0)[0] != 0x0003:
return None # not binary XML
if struct.unpack_from('<H', blob, 8)[0] != 0x0001:
@@ -854,7 +854,7 @@ def _write_aligned_zip(out_path, plan):
def _emit_filler(out, offset, size):
"""Insert a stored, zero-filled entry of exactly `size` payload bytes."""
import struct
# noqa: F401
import zlib
name_b = FILLER_NAME.encode('utf-8')
payload = b'\x00' * size
@@ -1422,7 +1422,6 @@ def main():
args = ap.parse_args()
tools = resolve_tools(args)
signer_jar = args.signer_jar or os.environ.get('APK_SIGNER_JAR', 'uber-apk-signer.jar')
split_mode = bool(args.split_dir or args.split)
if not split_mode:
+1 -1
View File
@@ -256,7 +256,7 @@ def main():
else:
if not args.pkg:
logger.line(host_ts() + ' FATAL --pkg is required when attaching '
'(or use --spawn with --pkg)')
'(or use --spawn with --pkg)')
return 3
pid, raw = get_pid(adb, args.device, args.pkg)
if pid is None:
+1 -1
View File
@@ -55,7 +55,6 @@ is still scanned even if it sits under an excluded name.
Pure standard library, python3, no third-party imports. POSIX and Windows.
"""
from __future__ import annotations
import argparse
import json
@@ -375,6 +374,7 @@ def build_rules():
# Walking
# --------------------------------------------------------------------------------------
TEXT_EXTENSIONS = (".md", ".py", ".js", ".json", ".txt", ".yml", ".yaml", ".sh", ".ps1",
".toml", ".cfg", ".ini", ".xml", ".java", ".smali", ".html", ".csv")
-3
View File
@@ -28,9 +28,6 @@ Notes
"""
import argparse
import io
import struct
import subprocess
import sys
import time
import zipfile
-1
View File
@@ -43,7 +43,6 @@ Reading the output
* Identical hashes across samples -> nothing is changing. Stop waiting and go
find out why (this is the stall detector).
"""
from __future__ import annotations
import argparse
import hashlib
@@ -100,7 +100,6 @@ Exit codes (see references/long-task-discipline.md and the kit-wide convention):
``evidence``, ``warnings``, ``next_action``) followed by the same final
``RESULT=<token>`` line every other script in this kit ends with.
"""
from __future__ import annotations
import argparse
import hashlib
@@ -49,7 +49,10 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
try:
import dexutil
except ImportError: # pragma: no cover
dexutil = None
# The optional-dependency idiom this repository uses: the name is rebound to None so the caller
# can test for it. mypy objects because `dexutil` is now "may be None", which is exactly the
# truth the `if dexutil is None` guards below rely on -- say so rather than narrowing the type.
dexutil = None # type: ignore[assignment]
# ---------------------------------------------------------------------------
@@ -1327,8 +1330,8 @@ def cmd_compare(args):
"orig": op, "orig_hex": "0x%02x" % op,
"name": dexutil.OP_NAMES[op],
"reason": UNREACHABLE.get(op) or
"the original never emits this opcode, so there is no "
"known-plaintext instance to read a substitution from",
("the original never emits this opcode, so there is no "
"known-plaintext instance to read a substitution from"),
})
# reverse direction: a private byte claimed by two different originals