Skip to content

Commit

Permalink
fix: py3.9 不支持 | None
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 6, 2024
1 parent 5460838 commit 7788212
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/MaaDebugger/maafw/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from asyncify import asyncify
from pathlib import Path
from typing import Callable, List, Optional
from typing import Callable, List, Optional, Union

from maa.controller import AdbController, Win32Controller
from maa.tasker import Tasker, RecognitionDetail, NotificationHandler
Expand All @@ -14,10 +14,10 @@

class MaaFW:

resource: Resource | None
controller: AdbController | Win32Controller | None
tasker: Tasker | None
notification_handler: NotificationHandler | None
resource: Optional[Resource]
controller: Union[AdbController, Win32Controller, None]
tasker: Optional[Tasker]
notification_handler: Optional[NotificationHandler]

def __init__(self):
Toolkit.init_option("./")
Expand Down
3 changes: 2 additions & 1 deletion src/MaaDebugger/utils/arg_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
from typing import Optional

from ..port_checker import PortChecker

Expand All @@ -20,7 +21,7 @@ def get_port(self) -> int:
"""
Determine the port to use based on the provided arguments.
"""
specified_port: int | None = self.args.port
specified_port: Optional[int] = self.args.port

if specified_port is not None:
if PortChecker.is_port_in_use(specified_port):
Expand Down
4 changes: 2 additions & 2 deletions src/MaaDebugger/webpage/reco_page/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Tuple
from typing import Dict, Tuple, Optional

from nicegui import ui

Expand All @@ -24,7 +24,7 @@ async def reco_page(reco_id: int):

ui.separator()

details: RecognitionDetail | None = await maafw.get_reco_detail(reco_id)
details: Optional[RecognitionDetail] = await maafw.get_reco_detail(reco_id)
if not details:
ui.markdown("## Not Found")
return
Expand Down

0 comments on commit 7788212

Please sign in to comment.