From d2a61b4a89d74732de6f50ed7ce00317638653d7 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 10 Oct 2026 05:29:38 +0200 Subject: [PATCH] refactor: name the new exceptions as errors --- install.ps1 | 2 +- install.py | 6 +++--- install.sh | 2 +- scripts/refresh_data_dirs.py | 8 ++++---- scripts/release_record.py | 8 ++++---- tests/test_pack_counts.py | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/install.ps1 b/install.ps1 index 93c025ba..1832895f 100644 --- a/install.ps1 +++ b/install.ps1 @@ -8,7 +8,7 @@ param( $ErrorActionPreference = "Stop" $defaultInstallUrl = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -$defaultInstallSha256 = "edc57fe82a964b271bdae9d20985421f7a6ba88859f9c6926f323c909ec2d651" +$defaultInstallSha256 = "0ed41bd31c30985281983309ec97162a7ae0176d737340bb728103efabae81f1" $maximumInstallerBytes = 2MB $installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null } $temporary = $null diff --git a/install.py b/install.py index f88590db..6123e0e9 100644 --- a/install.py +++ b/install.py @@ -1104,7 +1104,7 @@ def _region_rank(file_regions: set[str], requested: list[str]) -> int: def region_drops( - entries: list[dict], requested: list[str], systems: "list[str] | None" = None + entries: list[dict], requested: list[str], systems: list[str] | None = None ) -> set[str]: """Destinations a region priority list withdraws. @@ -1807,7 +1807,7 @@ def _pick(title: str, rows: list[tuple[str, list[dict]]], ordered: bool = False) def _prompt_custom_selection( plat: str, files: list[dict], omitted: list[dict] -) -> "tuple[list[str], list[str], list[str]] | None": +) -> tuple[list[str], list[str], list[str]] | None: """Offer to narrow the install by system, core and region. Enter installs everything, the default most runs want. Returns None @@ -1893,7 +1893,7 @@ def _print_choices( def _requested_narrowing( args: argparse.Namespace, plat: str, files: list[dict], omitted: list[dict] -) -> "tuple[list[str], list[str], list[str]] | None": +) -> tuple[list[str], list[str], list[str]] | None: """The systems, cores and regions named on the command line, checked.""" if not (args.system or args.core or args.region): return None diff --git a/install.sh b/install.sh index 231ad57a..9783cd93 100755 --- a/install.sh +++ b/install.sh @@ -18,7 +18,7 @@ esac TEMP_INSTALLER="" TEMP_DIRECTORY="" DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/install.py" -DEFAULT_INSTALL_SHA256="edc57fe82a964b271bdae9d20985421f7a6ba88859f9c6926f323c909ec2d651" +DEFAULT_INSTALL_SHA256="0ed41bd31c30985281983309ec97162a7ae0176d737340bb728103efabae81f1" MAX_INSTALLER_BYTES=2097152 cleanup() { diff --git a/scripts/refresh_data_dirs.py b/scripts/refresh_data_dirs.py index a34b6d35..a7121830 100644 --- a/scripts/refresh_data_dirs.py +++ b/scripts/refresh_data_dirs.py @@ -189,7 +189,7 @@ def get_remote_sha(source_url: str, version: str) -> str | None: return None -class NothingExtracted(Exception): +class NothingExtractedError(Exception): """An archive that yields no file for the cache. Promoting it replaced the cache with an empty directory, recorded the new @@ -282,7 +282,7 @@ def _download_and_extract( file_count += 1 if not file_count: - raise NothingExtracted(f"no file under {source_path} in the archive") + raise NothingExtractedError(f"no file under {source_path} in the archive") _promote(extract_dir, cache_dir, Path(tmpdir)) return file_count @@ -345,7 +345,7 @@ def _download_and_extract_zip( file_count += 1 if not file_count: - raise NothingExtracted("the archive holds no file to extract") + raise NothingExtractedError("the archive holds no file to extract") # The old tree is stepped aside rather than deleted: removing it # first and then failing to move the new one in left the cache with # nothing at all, and the next run reads that as "never fetched". @@ -451,7 +451,7 @@ def _refresh_entry( OSError, tarfile.TarError, zipfile.BadZipFile, - NothingExtracted, + NothingExtractedError, ) as exc: log.warning("[%s] download failed: %s", key, exc) return None diff --git a/scripts/release_record.py b/scripts/release_record.py index 08d3c8f9..2e775cbf 100644 --- a/scripts/release_record.py +++ b/scripts/release_record.py @@ -34,7 +34,7 @@ def _match_key(value: str) -> str: return re.sub(r"[^a-z0-9]", "", value.lower()) -class UnfinishedSplit(Exception): +class UnfinishedSplitError(Exception): """A pack lies beside its own parts: a split is running or was killed.""" @@ -54,10 +54,10 @@ def _read_record(dist: Path, tag: str) -> dict: assets: dict[str, list[Path]] = {} for path in sorted(dist.glob("*_BIOS_Pack*.zip")): assets.setdefault(split_pack.pack_of(path.name), []).append(path) - for name, paths in sorted(assets.items()): + for paths in assets.values(): whole = [p for p in paths if not split_pack.is_part(p.name)] if whole and len(paths) > len(whole): - raise UnfinishedSplit( + raise UnfinishedSplitError( f"{whole[0].name} lies beside its parts: the split did not finish" ) @@ -133,7 +133,7 @@ def main() -> int: try: record = build_record(args.dist, args.tag) - except (UnfinishedSplit, ArtifactLockBusy) as exc: + except (UnfinishedSplitError, ArtifactLockBusy) as exc: print(f"Error: {exc}", file=sys.stderr) return 1 if not record["packs"]: diff --git a/tests/test_pack_counts.py b/tests/test_pack_counts.py index 9dea1114..1390839a 100644 --- a/tests/test_pack_counts.py +++ b/tests/test_pack_counts.py @@ -359,7 +359,7 @@ class ReleaseRecord(unittest.TestCase): "Demo_2.0_BIOS_Pack.zip", {f"dir/file{n}.bin": bytes([n]) * 700 + bytes(range(256)) for n in range(6)}, ) - with self.assertRaises(release_record.UnfinishedSplit): + with self.assertRaises(release_record.UnfinishedSplitError): release_record.build_record(self.dist, "v1") def test_a_directory_being_written_is_not_read(self):