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

some worlds: some typing in LocalRom #3090

Merged
merged 6 commits into from
May 17, 2024
Merged
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 worlds/alttp/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import threading
import concurrent.futures
import bsdiff4
from typing import Optional, List
from typing import Collection, Optional, List, SupportsIndex

from BaseClasses import CollectionState, Region, Location, MultiWorld
from Utils import local_path, user_path, int16_as_bytes, int32_as_bytes, snes_to_pc, is_frozen, parse_yaml, read_snes_rom
Expand Down Expand Up @@ -52,7 +52,7 @@
enemizer_logger = logging.getLogger("Enemizer")


class LocalRom(object):
class LocalRom:

def __init__(self, file, patch=True, vanillaRom=None, name=None, hash=None):
self.name = name
Expand All @@ -71,13 +71,13 @@ def __init__(self, file, patch=True, vanillaRom=None, name=None, hash=None):
def read_byte(self, address: int) -> int:
return self.buffer[address]

def read_bytes(self, startaddress: int, length: int) -> bytes:
def read_bytes(self, startaddress: int, length: int) -> bytearray:
return self.buffer[startaddress:startaddress + length]

def write_byte(self, address: int, value: int):
self.buffer[address] = value

def write_bytes(self, startaddress: int, values):
def write_bytes(self, startaddress: int, values: Collection[SupportsIndex]) -> None:
self.buffer[startaddress:startaddress + len(values)] = values

def encrypt_range(self, startaddress: int, length: int, key: bytes):
Expand Down
4 changes: 2 additions & 2 deletions worlds/dkc3/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@
0x21,
]

class LocalRom(object):
class LocalRom:

def __init__(self, file, patch=True, vanillaRom=None, name=None, hash=None):
self.name = name
Expand All @@ -457,7 +457,7 @@ def read_bit(self, address: int, bit_number: int) -> bool:
def read_byte(self, address: int) -> int:
return self.buffer[address]

def read_bytes(self, startaddress: int, length: int) -> bytes:
def read_bytes(self, startaddress: int, length: int) -> bytearray:
return self.buffer[startaddress:startaddress + length]

def write_byte(self, address: int, value: int):
Expand Down
2 changes: 1 addition & 1 deletion worlds/smw/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def read_bit(self, address: int, bit_number: int) -> bool:
def read_byte(self, address: int) -> int:
return self.buffer[address]

def read_bytes(self, startaddress: int, length: int) -> bytes:
def read_bytes(self, startaddress: int, length: int) -> bytearray:
return self.buffer[startaddress:startaddress + length]

def write_byte(self, address: int, value: int):
Expand Down
8 changes: 4 additions & 4 deletions worlds/yoshisisland/Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Utils
from worlds.Files import APDeltaPatch
from settings import get_settings
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Collection, SupportsIndex

from .Options import YoshiColors, BowserDoor, PlayerGoal, MinigameChecks

Expand Down Expand Up @@ -396,7 +396,7 @@
0x30510B: [0x14B2, 4]
}

class LocalRom(object):
class LocalRom:

def __init__(self, file: str) -> None:
self.name = None
Expand All @@ -413,13 +413,13 @@ def read_bit(self, address: int, bit_number: int) -> bool:
def read_byte(self, address: int) -> int:
return self.buffer[address]

def read_bytes(self, startaddress: int, length: int) -> bytes:
def read_bytes(self, startaddress: int, length: int) -> bytearray:
return self.buffer[startaddress:startaddress + length]

def write_byte(self, address: int, value: int) -> None:
self.buffer[address] = value

def write_bytes(self, startaddress: int, values: bytearray) -> None:
def write_bytes(self, startaddress: int, values: Collection[SupportsIndex]) -> None:
self.buffer[startaddress:startaddress + len(values)] = values

def write_to_file(self, file: str) -> None:
Expand Down
Loading