mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-03-23 16:43:23 -07:00
More type hint updates.
This commit is contained in:
@@ -10,7 +10,7 @@ import colorama
|
||||
import asyncio
|
||||
from asyncio import Task
|
||||
|
||||
from typing import Set, Awaitable, Optional
|
||||
from typing import Set, Awaitable
|
||||
|
||||
import pymem
|
||||
from pymem.exception import ProcessNotFound
|
||||
@@ -90,7 +90,7 @@ class JakAndDaxterContext(CommonContext):
|
||||
repl_task: asyncio.Task
|
||||
memr_task: asyncio.Task
|
||||
|
||||
def __init__(self, server_address: Optional[str], password: Optional[str]) -> None:
|
||||
def __init__(self, server_address: str | None, password: str | None) -> None:
|
||||
self.repl = JakAndDaxterReplClient(self.on_log_error,
|
||||
self.on_log_warn,
|
||||
self.on_log_success,
|
||||
@@ -175,10 +175,10 @@ class JakAndDaxterContext(CommonContext):
|
||||
|
||||
async def json_to_game_text(self, args: dict):
|
||||
if "type" in args and args["type"] in {"ItemSend"}:
|
||||
my_item_name: Optional[str] = None
|
||||
my_item_finder: Optional[str] = None
|
||||
their_item_name: Optional[str] = None
|
||||
their_item_owner: Optional[str] = None
|
||||
my_item_name: str | None = None
|
||||
my_item_finder: str | None = None
|
||||
their_item_name: str | None = None
|
||||
their_item_owner: str | None = None
|
||||
|
||||
item = args["item"]
|
||||
recipient = args["receiving"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, ClassVar, Callable, Optional, Union
|
||||
from typing import Any, ClassVar, Callable
|
||||
from math import ceil
|
||||
import Utils
|
||||
import settings
|
||||
@@ -66,8 +66,8 @@ class JakAndDaxterSettings(settings.Group):
|
||||
|
||||
root_directory: RootDirectory = RootDirectory(
|
||||
"%programfiles%/OpenGOAL-Launcher/features/jak1/mods/JakMods/archipelagoal")
|
||||
auto_detect_root_directory: Union[AutoDetectRootDirectory, bool] = True
|
||||
enforce_friendly_options: Union[EnforceFriendlyOptions, bool] = True
|
||||
auto_detect_root_directory: AutoDetectRootDirectory | bool = True
|
||||
enforce_friendly_options: EnforceFriendlyOptions | bool = True
|
||||
|
||||
|
||||
class JakAndDaxterWebWorld(WebWorld):
|
||||
@@ -195,7 +195,7 @@ class JakAndDaxterWorld(World):
|
||||
|
||||
# These functions and variables are Options-driven, keep them as instance variables here so that we don't clog up
|
||||
# the seed generation routines with options checking. So we set these once, and then just use them as needed.
|
||||
can_trade: Callable[[CollectionState, int, Optional[int]], bool]
|
||||
can_trade: Callable[[CollectionState, int, int | None], bool]
|
||||
orb_bundle_item_name: str = ""
|
||||
orb_bundle_size: int = 0
|
||||
total_trade_orbs: int = 0
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import random
|
||||
import struct
|
||||
from typing import ByteString, Callable, Optional
|
||||
from typing import ByteString, Callable
|
||||
import json
|
||||
import pymem
|
||||
from pymem import pattern
|
||||
@@ -297,7 +297,7 @@ class JakAndDaxterMemoryReader:
|
||||
if not self.connected:
|
||||
self.log_error(logger, "The Memory Reader is not connected!")
|
||||
|
||||
memory_version: Optional[int] = None
|
||||
memory_version: int | None = None
|
||||
try:
|
||||
memory_version = self.read_goal_address(memory_version_offset, sizeof_uint32)
|
||||
if memory_version == expected_memory_version:
|
||||
|
||||
@@ -6,7 +6,7 @@ import struct
|
||||
import random
|
||||
from dataclasses import dataclass
|
||||
from queue import Queue
|
||||
from typing import Optional, Callable
|
||||
from typing import Callable
|
||||
|
||||
import pymem
|
||||
from pymem.exception import ProcessNotFound, ProcessError
|
||||
@@ -30,10 +30,10 @@ logger = logging.getLogger("ReplClient")
|
||||
|
||||
@dataclass
|
||||
class JsonMessageData:
|
||||
my_item_name: Optional[str] = None
|
||||
my_item_finder: Optional[str] = None
|
||||
their_item_name: Optional[str] = None
|
||||
their_item_owner: Optional[str] = None
|
||||
my_item_name: str | None = None
|
||||
my_item_finder: str | None = None
|
||||
their_item_name: str | None = None
|
||||
their_item_owner: str | None = None
|
||||
|
||||
|
||||
class JakAndDaxterReplClient:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Iterable, Callable, Optional
|
||||
from typing import Iterable
|
||||
from BaseClasses import MultiWorld, Region
|
||||
from ..GameID import jak1_name
|
||||
from ..Locations import JakAndDaxterLocation, location_table
|
||||
@@ -7,6 +7,7 @@ from ..locs import (OrbLocations as Orbs,
|
||||
ScoutLocations as Scouts,
|
||||
SpecialLocations as Specials,
|
||||
OrbCacheLocations as Caches)
|
||||
from worlds.generic.Rules import CollectionRule
|
||||
|
||||
|
||||
class JakAndDaxterRegion(Region):
|
||||
@@ -25,7 +26,7 @@ class JakAndDaxterRegion(Region):
|
||||
self.level_name = level_name
|
||||
self.orb_count = orb_count
|
||||
|
||||
def add_cell_locations(self, locations: Iterable[int], access_rule: Optional[Callable] = None):
|
||||
def add_cell_locations(self, locations: Iterable[int], access_rule: CollectionRule | None = None) -> None:
|
||||
"""
|
||||
Adds a Power Cell Location to this region with the given access rule.
|
||||
Converts Game ID's to AP ID's for you.
|
||||
@@ -34,7 +35,7 @@ class JakAndDaxterRegion(Region):
|
||||
ap_id = Cells.to_ap_id(loc)
|
||||
self.add_jak_locations(ap_id, location_table[ap_id], access_rule)
|
||||
|
||||
def add_fly_locations(self, locations: Iterable[int], access_rule: Optional[Callable] = None):
|
||||
def add_fly_locations(self, locations: Iterable[int], access_rule: CollectionRule | None = None) -> None:
|
||||
"""
|
||||
Adds a Scout Fly Location to this region with the given access rule.
|
||||
Converts Game ID's to AP ID's for you.
|
||||
@@ -43,7 +44,7 @@ class JakAndDaxterRegion(Region):
|
||||
ap_id = Scouts.to_ap_id(loc)
|
||||
self.add_jak_locations(ap_id, location_table[ap_id], access_rule)
|
||||
|
||||
def add_special_locations(self, locations: Iterable[int], access_rule: Optional[Callable] = None):
|
||||
def add_special_locations(self, locations: Iterable[int], access_rule: CollectionRule | None = None) -> None:
|
||||
"""
|
||||
Adds a Special Location to this region with the given access rule.
|
||||
Converts Game ID's to AP ID's for you.
|
||||
@@ -54,7 +55,7 @@ class JakAndDaxterRegion(Region):
|
||||
ap_id = Specials.to_ap_id(loc)
|
||||
self.add_jak_locations(ap_id, location_table[ap_id], access_rule)
|
||||
|
||||
def add_cache_locations(self, locations: Iterable[int], access_rule: Optional[Callable] = None):
|
||||
def add_cache_locations(self, locations: Iterable[int], access_rule: CollectionRule | None = None) -> None:
|
||||
"""
|
||||
Adds an Orb Cache Location to this region with the given access rule.
|
||||
Converts Game ID's to AP ID's for you.
|
||||
@@ -63,7 +64,7 @@ class JakAndDaxterRegion(Region):
|
||||
ap_id = Caches.to_ap_id(loc)
|
||||
self.add_jak_locations(ap_id, location_table[ap_id], access_rule)
|
||||
|
||||
def add_orb_locations(self, level_index: int, bundle_index: int, access_rule: Optional[Callable] = None):
|
||||
def add_orb_locations(self, level_index: int, bundle_index: int, access_rule: CollectionRule | None = None) -> None:
|
||||
"""
|
||||
Adds Orb Bundle Locations to this region equal to `bundle_count`. Used only when Per-Level Orbsanity is enabled.
|
||||
The orb factory class will handle AP ID enumeration.
|
||||
@@ -77,7 +78,7 @@ class JakAndDaxterRegion(Region):
|
||||
location.access_rule = access_rule
|
||||
self.locations.append(location)
|
||||
|
||||
def add_jak_locations(self, ap_id: int, name: str, access_rule: Optional[Callable] = None):
|
||||
def add_jak_locations(self, ap_id: int, name: str, access_rule: CollectionRule | None = None) -> None:
|
||||
"""
|
||||
Helper function to add Locations. Not to be used directly.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user