Skip to content

Commit 4b9afb1

Browse files
committed
scripted-diff: use PEP 585 built-in collection types for verify-binary script
-BEGIN VERIFY SCRIPT- sed -i 's|t\.Dict|dict|g' ./contrib/verify-binaries/verify.py sed -i 's|t\.List|list|g' ./contrib/verify-binaries/verify.py sed -i 's|t\.Tuple|tuple|g' ./contrib/verify-binaries/verify.py -END VERIFY SCRIPT-
1 parent d516cf8 commit 4b9afb1

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

contrib/verify-binaries/verify.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def download_with_wget(remote_file, local_file):
122122
return result.returncode == 0, result.stdout.decode().rstrip()
123123

124124

125-
def download_lines_with_urllib(url) -> t.Tuple[bool, t.List[str]]:
125+
def download_lines_with_urllib(url) -> tuple[bool, list[str]]:
126126
"""Get (success, text lines of a file) over HTTP."""
127127
try:
128128
return (True, [
@@ -138,7 +138,7 @@ def verify_with_gpg(
138138
filename,
139139
signature_filename,
140140
output_filename: t.Optional[str] = None
141-
) -> t.Tuple[int, str]:
141+
) -> tuple[int, str]:
142142
with tempfile.NamedTemporaryFile() as status_file:
143143
args = [
144144
'gpg', '--yes', '--verify', '--verify-options', 'show-primary-uid-only', "--status-file", status_file.name,
@@ -177,12 +177,12 @@ def __repr__(self):
177177

178178

179179
def parse_gpg_result(
180-
output: t.List[str]
181-
) -> t.Tuple[t.List[SigData], t.List[SigData], t.List[SigData]]:
180+
output: list[str]
181+
) -> tuple[list[SigData], list[SigData], list[SigData]]:
182182
"""Returns good, unknown, and bad signatures from GPG stdout."""
183-
good_sigs: t.List[SigData] = []
184-
unknown_sigs: t.List[SigData] = []
185-
bad_sigs: t.List[SigData] = []
183+
good_sigs: list[SigData] = []
184+
unknown_sigs: list[SigData] = []
185+
bad_sigs: list[SigData] = []
186186
total_resolved_sigs = 0
187187

188188
# Ensure that all lines we match on include a prefix that prevents malicious input
@@ -265,7 +265,7 @@ def files_are_equal(filename1, filename2):
265265

266266

267267
def get_files_from_hosts_and_compare(
268-
hosts: t.List[str], path: str, filename: str, require_all: bool = False
268+
hosts: list[str], path: str, filename: str, require_all: bool = False
269269
) -> ReturnCode:
270270
"""
271271
Retrieve the same file from a number of hosts and ensure they have the same contents.
@@ -326,7 +326,7 @@ def join_url(host: str) -> str:
326326
return ReturnCode.SUCCESS
327327

328328

329-
def check_multisig(sums_file: str, sigfilename: str, args: argparse.Namespace) -> t.Tuple[int, str, t.List[SigData], t.List[SigData], t.List[SigData]]:
329+
def check_multisig(sums_file: str, sigfilename: str, args: argparse.Namespace) -> tuple[int, str, list[SigData], list[SigData], list[SigData]]:
330330
# check signature
331331
#
332332
# We don't write output to a file because this command will almost certainly
@@ -365,8 +365,8 @@ def prompt_yn(prompt) -> bool:
365365

366366
def verify_shasums_signature(
367367
signature_file_path: str, sums_file_path: str, args: argparse.Namespace
368-
) -> t.Tuple[
369-
ReturnCode, t.List[SigData], t.List[SigData], t.List[SigData], t.List[SigData]
368+
) -> tuple[
369+
ReturnCode, list[SigData], list[SigData], list[SigData], list[SigData]
370370
]:
371371
min_good_sigs = args.min_good_sigs
372372
gpg_allowed_codes = [0, 2] # 2 is returned when untrusted signatures are present.
@@ -429,14 +429,14 @@ def verify_shasums_signature(
429429
return (ReturnCode.SUCCESS, good_trusted, good_untrusted, unknown, bad)
430430

431431

432-
def parse_sums_file(sums_file_path: str, filename_filter: t.List[str]) -> t.List[t.List[str]]:
432+
def parse_sums_file(sums_file_path: str, filename_filter: list[str]) -> list[list[str]]:
433433
# extract hashes/filenames of binaries to verify from hash file;
434434
# each line has the following format: "<hash> <binary_filename>"
435435
with open(sums_file_path, 'r', encoding='utf8') as hash_file:
436436
return [line.split()[:2] for line in hash_file if len(filename_filter) == 0 or any(f in line for f in filename_filter)]
437437

438438

439-
def verify_binary_hashes(hashes_to_verify: t.List[t.List[str]]) -> t.Tuple[ReturnCode, t.Dict[str, str]]:
439+
def verify_binary_hashes(hashes_to_verify: list[list[str]]) -> tuple[ReturnCode, dict[str, str]]:
440440
offending_files = []
441441
files_to_hashes = {}
442442

0 commit comments

Comments
 (0)