Skip to content

Commit 940408f

Browse files
committed
Use TYPE_CHECKING instead of base class
1 parent d1938bc commit 940408f

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/Helpers.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import json
44

55
from BaseClasses import MultiWorld, Item, Location
6-
from typing import Optional, List
6+
from typing import Optional, List, TYPE_CHECKING
77
from worlds.AutoWorld import World
88
from .hooks.Helpers import before_is_category_enabled, before_is_item_enabled, before_is_location_enabled
99

1010
from typing import Union
1111

12+
if TYPE_CHECKING:
13+
from .Items import ManualItem
14+
from .Locations import ManualLocation
15+
1216
# blatantly copied from the minecraft ap world because why not
1317
def load_data_file(*args) -> dict:
1418
fname = os.path.join("data", *args)
@@ -69,7 +73,7 @@ def is_item_name_enabled(multiworld: MultiWorld, player: int, item_name: str) ->
6973

7074
return is_item_enabled(multiworld, player, item)
7175

72-
def is_item_enabled(multiworld: MultiWorld, player: int, item: Item) -> bool:
76+
def is_item_enabled(multiworld: MultiWorld, player: int, item: "ManualItem") -> bool:
7377
"""Check if an item has been disabled by a yaml option."""
7478
hook_result = before_is_item_enabled(multiworld, player, item)
7579
if hook_result is not None:
@@ -85,7 +89,7 @@ def is_location_name_enabled(multiworld: MultiWorld, player: int, location_name:
8589

8690
return is_location_enabled(multiworld, player, location)
8791

88-
def is_location_enabled(multiworld: MultiWorld, player: int, location: Location) -> bool:
92+
def is_location_enabled(multiworld: MultiWorld, player: int, location: "ManualLocation") -> bool:
8993
"""Check if a location has been disabled by a yaml option."""
9094
hook_result = before_is_location_enabled(multiworld, player, location)
9195
if hook_result is not None:

src/hooks/Helpers.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
from typing import Optional
1+
from typing import Optional, TYPE_CHECKING
22
from BaseClasses import MultiWorld, Item, Location
33

4+
if TYPE_CHECKING:
5+
from ..Items import ManualItem
6+
from ..Locations import ManualLocation
7+
48
# Use this if you want to override the default behavior of is_option_enabled
59
# Return True to enable the category, False to disable it, or None to use the default behavior
610
def before_is_category_enabled(multiworld: MultiWorld, player: int, category_name: str) -> Optional[bool]:
711
return None
812

913
# Use this if you want to override the default behavior of is_option_enabled
1014
# Return True to enable the item, False to disable it, or None to use the default behavior
11-
def before_is_item_enabled(multiworld: MultiWorld, player: int, item: Item) -> Optional[bool]:
15+
def before_is_item_enabled(multiworld: MultiWorld, player: int, item: "ManualItem") -> Optional[bool]:
1216
return None
1317

1418
# Use this if you want to override the default behavior of is_option_enabled
1519
# Return True to enable the location, False to disable it, or None to use the default behavior
16-
def before_is_location_enabled(multiworld: MultiWorld, player: int, location: Location) -> Optional[bool]:
20+
def before_is_location_enabled(multiworld: MultiWorld, player: int, location: "ManualLocation") -> Optional[bool]:
1721
return None

0 commit comments

Comments
 (0)