From e2342de9a329993abde0caf574e2c2275e330ca8 Mon Sep 17 00:00:00 2001 From: duncathan Date: Fri, 23 May 2025 16:29:34 -0600 Subject: [PATCH 1/3] bump minimum python version fixes #134 --- .github/workflows/python.yml | 3 +-- pyproject.toml | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index ca6727c..8f6da92 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.10" - name: Install core Python packages run: python -m pip install --upgrade pip setuptools build @@ -58,7 +58,6 @@ jobs: fail-fast: false matrix: python: - - {version: '3.9'} - {version: '3.10'} - {version: '3.11'} - {version: '3.12'} diff --git a/pyproject.toml b/pyproject.toml index b368408..5d80fa2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,12 +13,12 @@ authors = [ description = "An open source randomizer patcher for Metroid Fusion." readme = "README.md" license = {file = "LICENSE"} -requires-python = ">=3.9" +requires-python = ">=3.10" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Development Status :: 3 - Alpha", - "Programming Language :: Python :: 3.9" + "Programming Language :: Python :: 3.10" ] dependencies = [ From cfa5e7e4b66b950baeb417d0c839032cd06483f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 22:30:15 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/mars_patcher/common_types.py | 4 +--- src/mars_patcher/patcher.py | 6 +++--- src/mars_patcher/rom.py | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/mars_patcher/common_types.py b/src/mars_patcher/common_types.py index 6be881b..823298b 100644 --- a/src/mars_patcher/common_types.py +++ b/src/mars_patcher/common_types.py @@ -1,6 +1,4 @@ -from typing import Annotated - -from typing_extensions import TypeAlias +from typing import Annotated, TypeAlias from mars_patcher.auto_generated_types import Areaid, Typeu8 diff --git a/src/mars_patcher/patcher.py b/src/mars_patcher/patcher.py index 66ccb28..a801f61 100644 --- a/src/mars_patcher/patcher.py +++ b/src/mars_patcher/patcher.py @@ -1,7 +1,7 @@ import json import typing +from collections.abc import Callable from os import PathLike -from typing import Callable, Union from jsonschema import validate @@ -50,8 +50,8 @@ def validate_patch_data(patch_data: dict) -> MarsSchema: def patch( - input_path: Union[str, PathLike[str]], - output_path: Union[str, PathLike[str]], + input_path: str | PathLike[str], + output_path: str | PathLike[str], patch_data: MarsSchema, status_update: Callable[[str, float], None], ) -> None: diff --git a/src/mars_patcher/rom.py b/src/mars_patcher/rom.py index f20ef60..645bd3d 100644 --- a/src/mars_patcher/rom.py +++ b/src/mars_patcher/rom.py @@ -82,7 +82,7 @@ class Rom: }, } - def __init__(self, path: Union[str, PathLike[str]]): + def __init__(self, path: str | PathLike[str]): # Read file with open(path, "rb") as f: self.data = bytearray(f.read()) @@ -238,7 +238,7 @@ def reserve_free_space(self, size: int) -> int: raise RuntimeError("Ran out of reserved free space") return addr - def save(self, path: Union[str, PathLike[str]]) -> None: + def save(self, path: str | PathLike[str]) -> None: """Saves the currently loaded data to a specified path.""" with open(path, "wb") as f: f.write(self.data) From db22d5ffb210218851ab9a955871841626aa9595 Mon Sep 17 00:00:00 2001 From: duncathan Date: Fri, 23 May 2025 16:36:17 -0600 Subject: [PATCH 3/3] fixes --- src/mars_patcher/patcher.py | 2 +- src/mars_patcher/rom.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mars_patcher/patcher.py b/src/mars_patcher/patcher.py index a801f61..6a9cfe8 100644 --- a/src/mars_patcher/patcher.py +++ b/src/mars_patcher/patcher.py @@ -46,7 +46,7 @@ def validate_patch_data(patch_data: dict) -> MarsSchema: with open(get_data_path("schema.json")) as f: schema = json.load(f) validate(patch_data, schema) - return typing.cast(MarsSchema, patch_data) + return typing.cast("MarsSchema", patch_data) def patch( diff --git a/src/mars_patcher/rom.py b/src/mars_patcher/rom.py index 645bd3d..f08d309 100644 --- a/src/mars_patcher/rom.py +++ b/src/mars_patcher/rom.py @@ -1,10 +1,9 @@ from enum import Enum from os import PathLike -from typing import Union from mars_patcher.constants.reserved_space import ReservedConstants -BytesLike = Union[bytes, bytearray] +BytesLike = bytes | bytearray SIZE_8MB = 0x800000 ROM_OFFSET = 0x8000000