Skip to content

Commit

Permalink
fix: better type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
builder555 committed Feb 1, 2024
1 parent 17da2ea commit 1cde711
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions backend/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import argparse


def get_resource_path(relative_path, max_levels=3):
def get_resource_path(relative_path: str, max_levels: int = 3):
"""Get the absolute path to the resource, works for development and for PyInstaller"""
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = getattr(sys, "_MEIPASS", os.path.abspath("."))
Expand All @@ -19,7 +19,7 @@ def get_resource_path(relative_path, max_levels=3):
return os.path.join(base_path, relative_path)


def parse_cmd_args(default_host, default_port) -> argparse.Namespace:
def parse_cmd_args(default_host: str, default_port: int) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="PineSAM - Pinecil v2 Control")
parser.add_argument(
"host",
Expand Down
6 changes: 3 additions & 3 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import asyncio
import os
import sys
from pinecil_monitor import PinecilMonitor, PinecilFinder
from ws_server import CommandProcessor, WebSocketHandler
from version_checker import VersionChecker
import logging
import webbrowser
from io_utils import parse_cmd_args, get_resource_path
from rich.logging import RichHandler
import argparse

LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper()
timestamp_format = "%H:%M:%S"
Expand All @@ -22,7 +22,7 @@
DEFAULT_PORT = 8080


async def handle_ui_opening(args):
async def handle_ui_opening(args: argparse.Namespace):
host = args.host if args.host != "0.0.0.0" else "localhost"
if not args.no_open:
await asyncio.sleep(5)
Expand All @@ -32,7 +32,7 @@ async def handle_ui_opening(args):
logging.info(f"Open browser at http://{host}:{args.port}")


async def main(stop_event=asyncio.Event()):
async def main(stop_event: asyncio.Event = asyncio.Event()):
args = parse_cmd_args(DEFAULT_HOST, DEFAULT_PORT)
if not args.host or not args.port:
return
Expand Down
4 changes: 2 additions & 2 deletions backend/pinecil_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def __init__(self, finder: PinecilFinder, broadcast_func: Callable):
self.should_announce_not_found = True

@property
def pinecil(self):
def pinecil(self) -> Pinecil | None:
return self.pinecil_finder.selected

async def monitor(self, stop_event):
async def monitor(self, stop_event: asyncio.Event):
logging.info("Starting pinecil monitor")
while not stop_event.is_set():
if not self.pinecil_finder.pinecils:
Expand Down

0 comments on commit 1cde711

Please sign in to comment.