From debdabe595307a1d41f1ccd32eeb51f938b6c04a Mon Sep 17 00:00:00 2001 From: Silvris <58583688+Silvris@users.noreply.github.com> Date: Thu, 29 Feb 2024 12:42:37 -0600 Subject: [PATCH] remove unnecessary if statement --- worlds/Files.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/worlds/Files.py b/worlds/Files.py index 088822d8ae..067e902777 100644 --- a/worlds/Files.py +++ b/worlds/Files.py @@ -56,19 +56,17 @@ class AutoPatchExtensionRegister(type): @staticmethod def get_handler(game: str) -> Union[AutoPatchExtensionRegister, List[AutoPatchExtensionRegister]]: - if game in AutoPatchExtensionRegister.extension_types: - handler = AutoPatchExtensionRegister.extension_types.get(game) - if handler.required_extensions: - handlers = [handler] - for required in handler.required_extensions: - if required in AutoPatchExtensionRegister.extension_types: - handlers.append(AutoPatchExtensionRegister.extension_types.get(required)) - else: - raise NotImplementedError(f"No handler for {required}.") - return handlers - else: - return handler - return APPatchExtension + handler = AutoPatchExtensionRegister.extension_types.get(game, APPatchExtension) + if handler.required_extensions: + handlers = [handler] + for required in handler.required_extensions: + if required in AutoPatchExtensionRegister.extension_types: + handlers.append(AutoPatchExtensionRegister.extension_types.get(required)) + else: + raise NotImplementedError(f"No handler for {required}.") + return handlers + else: + return handler class APContainer: @@ -267,11 +265,11 @@ class APTokenMixin: """ tokens: List[ Tuple[int, int, - Union[ - bytes, # WRITE - Tuple[int, int], # COPY, RLE - int # AND_8, OR_8, XOR_8 - ]]] = [] + Union[ + bytes, # WRITE + Tuple[int, int], # COPY, RLE + int # AND_8, OR_8, XOR_8 + ]]] = [] def get_token_binary(self) -> bytes: """ @@ -365,4 +363,3 @@ class APPatchExtension(metaclass=AutoPatchExtensionRegister): inv = crc ^ 0xFFFF rom_data[0x7FDC:0x7FE0] = [inv & 0xFF, (inv >> 8) & 0xFF, crc & 0xFF, (crc >> 8) & 0xFF] return rom_data -