Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python 3.13 compatibility + Remove Python 3.9 #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Build Python wheels
uses: RalfG/[email protected]_x86_64
with:
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
package-path: src
run: |
python3 -m pip install --upgrade build
python3 -m build
working-directory: src
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand Down
8 changes: 4 additions & 4 deletions generator/pmdsky_debug_py_generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pmdsky_debug_py_generator.loader import Binary, Region


def has_all_else_optional(value: dict[Region, Optional[Any]], typ: str):
def has_all_else_optional(value: dict[Region, Any | None], typ: str):
has_all = not any(x is None for x in value.values())
has_none = all(x is None for x in value.values())
if has_none:
Expand All @@ -19,7 +19,7 @@ def has_all_else_optional(value: dict[Region, Optional[Any]], typ: str):
return f"Optional[{typ}]"


def make_relative(value: Union[None, int, list[int]], based_on: Optional[int]) -> Union[None, int, list[int]]:
def make_relative(value: None | int | list[int], based_on: int | None) -> None | int | list[int]:
if value is None or based_on is None:
return None
if isinstance(value, int):
Expand All @@ -29,7 +29,7 @@ def make_relative(value: Union[None, int, list[int]], based_on: Optional[int]) -
return [x - based_on for x in value]


def as_hex(value: Union[None, int, list[int]]) -> str:
def as_hex(value: None | int | list[int]) -> str:
if value is None:
return "None"
if isinstance(value, int):
Expand All @@ -55,7 +55,7 @@ def escape_py(value: str) -> str:
class File:
template_name: str
output_name: str
region: Optional[Region]
region: Region | None


def generate(
Expand Down
10 changes: 5 additions & 5 deletions generator/pmdsky_debug_py_generator/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Region(Enum):
JP_ITCM = "jp-itcm"

@classmethod
def from_str(cls, region_str: str) -> Optional[Region]:
def from_str(cls, region_str: str) -> Region | None:
region_str = region_str.lower()
if region_str == "na":
return Region.NA
Expand Down Expand Up @@ -156,9 +156,9 @@ class Loader:
"""
pmdsky_debug_dir: str
# Contains all loaded binaries. None if symbols weren't loaded yet.
_all_binaries: Optional[List[Binary]]
_all_binaries: list[Binary] | None
# Contains all loaded symbols, indexed by name. None if symbols weren't loaded yet.
_all_symbols: Optional[Dict[str, Symbol]]
_all_symbols: dict[str, Symbol] | None

def __init__(self, pmdsky_debug_dir: str):
self.pmdsky_debug_dir = pmdsky_debug_dir
Expand Down Expand Up @@ -197,7 +197,7 @@ def load(self):
self.add_types(data_headers_dir)
return self._all_binaries

def get_binaries(self) -> List[Binary]:
def get_binaries(self) -> list[Binary]:
"""
Gets all loaded binaries. If symbol information has not been laoded yet, it is loaded before returning
the result.
Expand All @@ -206,7 +206,7 @@ def get_binaries(self) -> List[Binary]:
self.load()
return self._all_binaries

def get_symbols(self) -> Dict[Symbol]:
def get_symbols(self) -> dict[Symbol]:
"""
Gets all loaded symbols in a dict. The dict uses symbol names as the key. If symbol information has not been
laoded yet, it is loaded before returning the result.
Expand Down
8 changes: 4 additions & 4 deletions generator/pmdsky_debug_py_generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, message: str, print_source: bool = False) -> None:
super().__init__(message)
self.print_source = print_source

def show(self, file: Optional[IO] = None) -> None:
def show(self, file: IO | None = None) -> None:
if file is None:
file = get_text_stderr()

Expand All @@ -36,15 +36,15 @@ def show(self, file: Optional[IO] = None) -> None:
echo(style(traceback.format_exc(), bg='red'), file=file)


def try_int(i: str, fallback: T) -> Union[int, T]:
def try_int(i: str, fallback: T) -> int | T:
try:
return int(i)
except (ValueError, TypeError):
pass
return fallback


def version_tuple(a: str) -> tuple[Union[int, str], ...]:
def version_tuple(a: str) -> tuple[int | str, ...]:
if a.startswith('v'):
a = a[1:]
return tuple(try_int(i, i) for i in VERSION_SPLIT_RE.split(a))
Expand Down Expand Up @@ -111,7 +111,7 @@ def run(
verbose: bool,
out_path: str, in_path: str,
package_name: str,
release: str, out_version: Optional[str] = None,
release: str, out_version: str | None = None,
):
"""Generator for pmdsky-debug-py."""
global verbose_mode
Expand Down
4 changes: 2 additions & 2 deletions generator/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
name = "pmdsky-debug-py-generator"
version = "1.1.0"
description = "Generator for pdmsky-debug-py."
requires-python = ">=3.9"
requires-python = ">=3.10"
license = { text = "MIT" }
authors = [
{ name = "Marco 'Capypara' Köpcke", email = "[email protected]" },
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python"
]
dependencies = [
Expand Down
4 changes: 2 additions & 2 deletions src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name = "pmdsky-debug-py"
version = "10.0.21"
description = "pmdsky-debug symbols for Python."
readme = "./README.rst"
requires-python = ">=3.9"
classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python",]
requires-python = ">=3.10"
classifiers = [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python",]
[[project.authors]]
name = "Marco 'Capypara' Köpcke"
email = "[email protected]"
Expand Down