diff --git a/worlds/soe/options.py b/worlds/soe/options.py index d357465218db..1f3ea61ac4b1 100644 --- a/worlds/soe/options.py +++ b/worlds/soe/options.py @@ -1,18 +1,18 @@ -import typing from dataclasses import dataclass +from typing import Any, cast, Dict, List, Tuple, Protocol from Options import AssembleOptions, Choice, DeathLink, DefaultOnToggle, PerGameCommonOptions, ProgressionBalancing, \ Range, Toggle # typing boilerplate -class FlagsProtocol(typing.Protocol): +class FlagsProtocol(Protocol): value: int default: int - flags: typing.List[str] + flags: List[str] -class FlagProtocol(typing.Protocol): +class FlagProtocol(Protocol): value: int default: int flag: str @@ -20,7 +20,7 @@ class FlagProtocol(typing.Protocol): # meta options class EvermizerFlags: - flags: typing.List[str] + flags: List[str] def to_flag(self: FlagsProtocol) -> str: return self.flags[self.value] @@ -202,13 +202,13 @@ class TrapCount(Range): # more meta options class ItemChanceMeta(AssembleOptions): - def __new__(mcs, name, bases, attrs): + def __new__(mcs, name: str, bases: Tuple[type], attrs: Dict[Any, Any]) -> "ItemChanceMeta": if 'item_name' in attrs: attrs["display_name"] = f"{attrs['item_name']} Chance" attrs["range_start"] = 0 attrs["range_end"] = 100 - - return super(ItemChanceMeta, mcs).__new__(mcs, name, bases, attrs) + cls = super(ItemChanceMeta, mcs).__new__(mcs, name, bases, attrs) + return cast(ItemChanceMeta, cls) class TrapChance(Range, metaclass=ItemChanceMeta): diff --git a/worlds/soe/patch.py b/worlds/soe/patch.py index f3cd8815c8b1..8270f2d86dfa 100644 --- a/worlds/soe/patch.py +++ b/worlds/soe/patch.py @@ -1,5 +1,5 @@ import os -from typing import Optional +from typing import BinaryIO, Optional import Utils from worlds.Files import APDeltaPatch @@ -30,7 +30,7 @@ def get_base_rom_path(file_name: Optional[str] = None) -> str: return file_name -def read_rom(stream, strip_header=True) -> bytes: +def read_rom(stream: BinaryIO, strip_header: bool=True) -> bytes: """Reads rom into bytearray and optionally strips off any smc header""" data = stream.read() if strip_header and len(data) % 0x400 == 0x200: