Skip to content

Commit a126dee

Browse files
authored
HK: some stuff ruff and pycodestyle complained about (#4523)
1 parent e2b9421 commit a126dee

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

worlds/hk/Options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def __init__(self, value):
333333
continue
334334
try:
335335
self.value[key] = CharmCost.from_any(data).value
336-
except ValueError as ex:
336+
except ValueError:
337337
# will fail schema afterwords
338338
self.value[key] = data
339339

worlds/hk/__init__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
import operator
88
from collections import defaultdict, Counter
99

10-
logger = logging.getLogger("Hollow Knight")
11-
12-
from .Items import item_table, lookup_type_to_names, item_name_groups
13-
from .Regions import create_regions
10+
from .Items import item_table, item_name_groups
1411
from .Rules import set_rules, cost_terms, _hk_can_beat_thk, _hk_siblings_ending, _hk_can_beat_radiance
1512
from .Options import hollow_knight_options, hollow_knight_randomize_options, Goal, WhitePalace, CostSanity, \
1613
shop_to_option, HKOptions, GrubHuntGoal
17-
from .ExtractedData import locations, starts, multi_locations, location_to_region_lookup, \
18-
event_names, item_effects, connectors, one_ways, vanilla_shop_costs, vanilla_location_costs
14+
from .ExtractedData import locations, starts, multi_locations, event_names, item_effects, connectors, \
15+
vanilla_shop_costs, vanilla_location_costs
1916
from .Charms import names as charm_names
2017

21-
from BaseClasses import Region, Location, MultiWorld, Item, LocationProgressType, Tutorial, ItemClassification, CollectionState
18+
from BaseClasses import Region, Location, MultiWorld, Item, LocationProgressType, Tutorial, ItemClassification, \
19+
CollectionState
2220
from worlds.AutoWorld import World, LogicMixin, WebWorld
2321

2422
from settings import Group, Bool
2523

24+
logger = logging.getLogger("Hollow Knight")
25+
2626

2727
class HollowKnightSettings(Group):
2828
class DisableMapModSpoilers(Bool):
@@ -160,7 +160,7 @@ class HKWeb(WebWorld):
160160

161161

162162
class HKWorld(World):
163-
"""Beneath the fading town of Dirtmouth sleeps a vast, ancient kingdom. Many are drawn beneath the surface,
163+
"""Beneath the fading town of Dirtmouth sleeps a vast, ancient kingdom. Many are drawn beneath the surface,
164164
searching for riches, or glory, or answers to old secrets.
165165
166166
As the enigmatic Knight, you’ll traverse the depths, unravel its mysteries and conquer its evils.
@@ -231,7 +231,6 @@ def white_palace_exclusions(self):
231231
def create_regions(self):
232232
menu_region: Region = create_region(self.multiworld, self.player, 'Menu')
233233
self.multiworld.regions.append(menu_region)
234-
# wp_exclusions = self.white_palace_exclusions()
235234

236235
# check for any goal that godhome events are relevant to
237236
all_event_names = event_names.copy()
@@ -241,21 +240,17 @@ def create_regions(self):
241240

242241
# Link regions
243242
for event_name in sorted(all_event_names):
244-
#if event_name in wp_exclusions:
245-
# continue
246243
loc = HKLocation(self.player, event_name, None, menu_region)
247244
loc.place_locked_item(HKItem(event_name,
248-
True, #event_name not in wp_exclusions,
245+
True,
249246
None, "Event", self.player))
250247
menu_region.locations.append(loc)
251248
for entry_transition, exit_transition in connectors.items():
252-
#if entry_transition in wp_exclusions:
253-
# continue
254249
if exit_transition:
255250
# if door logic fulfilled -> award vanilla target as event
256251
loc = HKLocation(self.player, entry_transition, None, menu_region)
257252
loc.place_locked_item(HKItem(exit_transition,
258-
True, #exit_transition not in wp_exclusions,
253+
True,
259254
None, "Event", self.player))
260255
menu_region.locations.append(loc)
261256

@@ -292,7 +287,10 @@ def _add(item_name: str, location_name: str, randomized: bool):
292287
if item_name in junk_replace:
293288
item_name = self.get_filler_item_name()
294289

295-
item = self.create_item(item_name) if not vanilla or location_name == "Start" or self.options.AddUnshuffledLocations else self.create_event(item_name)
290+
item = (self.create_item(item_name)
291+
if not vanilla or location_name == "Start" or self.options.AddUnshuffledLocations
292+
else self.create_event(item_name)
293+
)
296294

297295
if location_name == "Start":
298296
if item_name in randomized_starting_items:
@@ -347,8 +345,8 @@ def _add(item_name: str, location_name: str, randomized: bool):
347345
randomized = True
348346
_add("Elevator_Pass", "Elevator_Pass", randomized)
349347

350-
for shop, locations in self.created_multi_locations.items():
351-
for _ in range(len(locations), getattr(self.options, shop_to_option[shop]).value):
348+
for shop, shop_locations in self.created_multi_locations.items():
349+
for _ in range(len(shop_locations), getattr(self.options, shop_to_option[shop]).value):
352350
self.create_location(shop)
353351
unfilled_locations += 1
354352

@@ -358,7 +356,7 @@ def _add(item_name: str, location_name: str, randomized: bool):
358356

359357
# Add additional shop items, as needed.
360358
if additional_shop_items > 0:
361-
shops = list(shop for shop, locations in self.created_multi_locations.items() if len(locations) < 16)
359+
shops = [shop for shop, shop_locations in self.created_multi_locations.items() if len(shop_locations) < 16]
362360
if not self.options.EggShopSlots: # No eggshop, so don't place items there
363361
shops.remove('Egg_Shop')
364362

@@ -380,8 +378,8 @@ def _add(item_name: str, location_name: str, randomized: bool):
380378
self.sort_shops_by_cost()
381379

382380
def sort_shops_by_cost(self):
383-
for shop, locations in self.created_multi_locations.items():
384-
randomized_locations = list(loc for loc in locations if not loc.vanilla)
381+
for shop, shop_locations in self.created_multi_locations.items():
382+
randomized_locations = [loc for loc in shop_locations if not loc.vanilla]
385383
prices = sorted(
386384
(loc.costs for loc in randomized_locations),
387385
key=lambda costs: (len(costs),) + tuple(costs.values())
@@ -405,7 +403,7 @@ def _compute_weights(weights: dict, desc: str) -> typing.Dict[str, int]:
405403
return {k: v for k, v in weights.items() if v}
406404

407405
random = self.random
408-
hybrid_chance = getattr(self.options, f"CostSanityHybridChance").value
406+
hybrid_chance = getattr(self.options, "CostSanityHybridChance").value
409407
weights = {
410408
data.term: getattr(self.options, f"CostSanity{data.option}Weight").value
411409
for data in cost_terms.values()
@@ -493,7 +491,11 @@ def stage_pre_fill(cls, multiworld: "MultiWorld"):
493491
worlds = [world for world in multiworld.get_game_worlds(cls.game) if world.options.Goal in ["any", "grub_hunt"]]
494492
if worlds:
495493
grubs = [item for item in multiworld.get_items() if item.name == "Grub"]
496-
all_grub_players = [world.player for world in worlds if world.options.GrubHuntGoal == GrubHuntGoal.special_range_names["all"]]
494+
all_grub_players = [
495+
world.player
496+
for world in worlds
497+
if world.options.GrubHuntGoal == GrubHuntGoal.special_range_names["all"]
498+
]
497499

498500
if all_grub_players:
499501
group_lookup = defaultdict(set)
@@ -668,8 +670,8 @@ def stage_write_spoiler(cls, multiworld: MultiWorld, spoiler_handle):
668670
):
669671
spoiler_handle.write(f"\n{loc}: {loc.item} costing {loc.cost_text()}")
670672
else:
671-
for shop_name, locations in hk_world.created_multi_locations.items():
672-
for loc in locations:
673+
for shop_name, shop_locations in hk_world.created_multi_locations.items():
674+
for loc in shop_locations:
673675
spoiler_handle.write(f"\n{loc}: {loc.item} costing {loc.cost_text()}")
674676

675677
def get_multi_location_name(self, base: str, i: typing.Optional[int]) -> str:

worlds/hk/test/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from argparse import Namespace
33
from BaseClasses import CollectionState, MultiWorld
44
from Options import ItemLinks
5-
from test.bases import WorldTestBase
65
from worlds.AutoWorld import AutoWorldRegister, call_all
76
from .. import HKWorld
87

worlds/hk/test/test_grub_count.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from . import linkedTestHK, WorldTestBase
1+
from test.bases import WorldTestBase
22
from Options import ItemLinks
3+
from . import linkedTestHK
34

45

56
class test_grubcount_limited(linkedTestHK, WorldTestBase):

0 commit comments

Comments
 (0)