some worlds: some typing in LocalRom (#3090)

* some worlds: some typing in `LocalRom`

### `read_bytes`

It's not safe to return `bytearray` when we think it's `bytes`
```python
a = rom.read_bytes(8, 3)
hash(a)  # This won't crash, right?
```

### `write_bytes`

`Iterable[SupportsIndex]` is what's required for `bytearray.__setitem__(slice, values)`
We need to add `__len__` for the `len(values)` in this function.

* remove `object` inheritance
This commit is contained in:
Doug Hoskisson
2024-05-17 12:41:57 -07:00
committed by GitHub
parent 9ae7083bfc
commit 280b67f996
4 changed files with 11 additions and 11 deletions

View File

@@ -434,7 +434,7 @@ level_music_ids = [
0x21,
]
class LocalRom(object):
class LocalRom:
def __init__(self, file, patch=True, vanillaRom=None, name=None, hash=None):
self.name = name
@@ -457,7 +457,7 @@ class LocalRom(object):
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):