diff --git a/ASM/rom_diff.py b/ASM/rom_diff.py index c3d6294eb..6107cb16a 100755 --- a/ASM/rom_diff.py +++ b/ASM/rom_diff.py @@ -1,6 +1,5 @@ #!/usr/bin/env/python3 -import json import struct import sys diff --git a/CI.py b/CI.py index 25f976799..3b30db4c1 100644 --- a/CI.py +++ b/CI.py @@ -99,7 +99,7 @@ def check_hell_mode_tricks(fix_errors: bool = False) -> None: if set(presets['Hell Mode']['allowed_tricks']) == {trick['name'] for trick in logic_tricks.values()}: if presets['Hell Mode']['allowed_tricks'] != [trick['name'] for trick in logic_tricks.values()]: - error(f'Order of logic tricks in Hell Mode preset does not match definition order in SettingsList.py', True) + error('Order of logic tricks in Hell Mode preset does not match definition order in SettingsList.py', True) if fix_errors: presets['Hell Mode']['allowed_tricks'] = [trick['name'] for trick in logic_tricks.values()] @@ -207,7 +207,7 @@ def exit_ci(fix_errors: bool = False) -> NoReturn: print('Run `CI.py --fix --no_unit_tests` to automatically fix these errors.', file=sys.stderr) sys.exit(1) else: - print(f'CI checks successful.') + print('CI checks successful.') sys.exit(0) diff --git a/Dungeon.py b/Dungeon.py index 0ab2ec42c..e083149d9 100644 --- a/Dungeon.py +++ b/Dungeon.py @@ -1,6 +1,6 @@ from __future__ import annotations from collections.abc import Iterator -from typing import TYPE_CHECKING, Optional, Any +from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from Hints import HintArea diff --git a/Gui.py b/Gui.py index e7c7efb58..170895ec6 100755 --- a/Gui.py +++ b/Gui.py @@ -41,7 +41,7 @@ def gui_main() -> None: def version_check(name: str, version: str, url: str) -> None: try: process = subprocess.Popen([shutil.which(name.lower()), "--version"], stdout=subprocess.PIPE) - except Exception as ex: + except Exception: raise VersionError('{name} is not installed. Please install {name} {version} or later'.format(name=name, version=version), url) while True: diff --git a/Hints.py b/Hints.py index b561c6b0e..afd2008c2 100644 --- a/Hints.py +++ b/Hints.py @@ -7,7 +7,7 @@ import sys import urllib.request from collections import OrderedDict, defaultdict -from collections.abc import Callable, Iterable +from collections.abc import Iterable from enum import Enum from typing import TYPE_CHECKING, Optional from urllib.error import URLError, HTTPError @@ -27,7 +27,6 @@ TypeAlias = str if TYPE_CHECKING: - from Entrance import Entrance from Goals import GoalCategory from Location import Location from Spoiler import Spoiler diff --git a/Location.py b/Location.py index 3cabfdb32..12473d89b 100644 --- a/Location.py +++ b/Location.py @@ -2,7 +2,7 @@ import logging from collections.abc import Callable, Iterable from enum import Enum -from typing import TYPE_CHECKING, Optional, Any, overload +from typing import TYPE_CHECKING, Optional, overload from HintList import misc_item_hint_table, misc_location_hint_table from LocationList import location_table, location_is_viewable, LocationAddress, LocationDefault, LocationFilterTags diff --git a/Music.py b/Music.py index 74bb47b3c..9c43257fd 100644 --- a/Music.py +++ b/Music.py @@ -277,7 +277,7 @@ def process_sequences(rom: Rom, ids: Iterable[tuple[str, int]], seq_type: str = lines = io.TextIOWrapper(stream).readlines() # Use TextIOWrapper in order to get text instead of binary from the seq. # Strip newline(s) lines = [line.rstrip() for line in lines] - except Exception as ex: + except Exception: raise FileNotFoundError(f'Error reading meta file for: "{fname}". This should never happen') # Create new sequence, checking third line for correct type @@ -424,7 +424,7 @@ def rebuild_sequences(rom: Rom, sequences: list[Sequence], log: CosmeticsLog, sy if new_entry.size <= 0x10: raise Exception(f'Invalid sequence file "{seq.name}.seq"') new_entry.data[1] = 0x20 - except FileNotFoundError as ex: + except FileNotFoundError: raise FileNotFoundError(f'No sequence file for: "{seq.name}"') else: new_entry.size = old_sequences[i].size diff --git a/N64Patch.py b/N64Patch.py index 9c981370f..a872c8c80 100644 --- a/N64Patch.py +++ b/N64Patch.py @@ -189,7 +189,7 @@ def apply_patch_file(rom: Rom, settings: Settings, sub_file: Optional[str] = Non try: with patch_archive.open(sub_file, 'r') as stream: patch_data = stream.read() - except KeyError as ex: + except KeyError: raise FileNotFoundError('Patch file missing from archive. Invalid Player ID.') else: with open(file, 'rb') as stream: diff --git a/OcarinaSongs.py b/OcarinaSongs.py index 4b616b89b..3279adda3 100644 --- a/OcarinaSongs.py +++ b/OcarinaSongs.py @@ -1,7 +1,7 @@ from __future__ import annotations import random import sys -from collections.abc import Callable, Sequence +from collections.abc import Sequence from itertools import chain from typing import TYPE_CHECKING, Optional diff --git a/Patches.py b/Patches.py index b26b8dfb6..aa12c1673 100644 --- a/Patches.py +++ b/Patches.py @@ -1749,7 +1749,7 @@ def calculate_traded_flags(world): # Update "Princess Ruto got the Spiritual Stone!" text before the midboss in Jabu if reward_text is None or location is None or location.item is None: - new_message = f"\x08Princess Ruto got \x01\x05\x43nothing\x05\x40!\x01Well, that's disappointing...\x02" + new_message = "\x08Princess Ruto got \x01\x05\x43nothing\x05\x40!\x01Well, that's disappointing...\x02" else: reward_texts = { 'Kokiri Emerald': "the \x05\x42Kokiri Emerald\x05\x40", diff --git a/Region.py b/Region.py index 13fb4fd75..84bbc9016 100644 --- a/Region.py +++ b/Region.py @@ -1,6 +1,6 @@ from __future__ import annotations from enum import Enum, unique -from typing import TYPE_CHECKING, Optional, Any +from typing import TYPE_CHECKING, Optional if TYPE_CHECKING: from Dungeon import Dungeon diff --git a/Rom.py b/Rom.py index 0ba3419e8..2dc0bcdb0 100644 --- a/Rom.py +++ b/Rom.py @@ -70,7 +70,7 @@ def read_rom(self, input_file: str, output_file: Optional[str] = None, verify_cr try: with open(input_file, 'rb') as stream: self.buffer = bytearray(stream.read()) - except FileNotFoundError as ex: + except FileNotFoundError: raise FileNotFoundError(f'Invalid path to Base ROM: "{input_file}"') # Validate ROM file diff --git a/Settings.py b/Settings.py index 81305ebf9..428e7b23c 100644 --- a/Settings.py +++ b/Settings.py @@ -377,7 +377,7 @@ def to_json(self, *, legacy_starting_items: bool = False) -> dict[str, Any]: ('_settings' in self.distribution.src_dict and setting.name in self.distribution.src_dict['_settings'].keys()) ) # Don't want to include list starting equipment and songs, these are consolidated into starting_items - and (legacy_starting_items or not (setting.name in LEGACY_STARTING_ITEM_SETTINGS)) + and (legacy_starting_items or setting.name not in LEGACY_STARTING_ITEM_SETTINGS) and (setting.name != 'starting_items' or not legacy_starting_items) } diff --git a/Spoiler.py b/Spoiler.py index 90764b00d..a0fa59e52 100644 --- a/Spoiler.py +++ b/Spoiler.py @@ -3,7 +3,7 @@ import random from collections import OrderedDict from itertools import chain -from typing import TYPE_CHECKING, Any +from typing import TYPE_CHECKING from Item import Item from LocationList import location_sort_order diff --git a/Unittest.py b/Unittest.py index faec3a667..2a20363ca 100644 --- a/Unittest.py +++ b/Unittest.py @@ -847,7 +847,7 @@ def test_fuzzer(self): self.verify_woth(spoiler) self.verify_playthrough(spoiler) self.verify_disables(spoiler) - except Exception as e: + except Exception: # output the settings file in case of any failure with open(settings_file, 'w') as f: d = {k: settings.settings_dict[k] for k in out_keys} diff --git a/World.py b/World.py index 4161fcfbd..d9b363f07 100644 --- a/World.py +++ b/World.py @@ -861,7 +861,7 @@ def set_goals(self) -> None: # one copy if the other is unreachable. # # Similar criteria is used for Ganon's Boss Key in plentiful keysanity. - if not 'Light Arrows' in self.item_added_hint_types['always']: + if 'Light Arrows' not in self.item_added_hint_types['always']: if self.settings.item_pool_value == 'plentiful': arrows = 2 else: @@ -1281,7 +1281,7 @@ def update_useless_areas(self, spoiler: Spoiler) -> None: exclude_item_list.remove(i) for i in self.item_added_hint_types['barren']: - if not (i in exclude_item_list): + if i not in exclude_item_list: exclude_item_list.append(i) # The idea here is that if an item shows up in woth, then the only way