fix: minor typing fix

This commit is contained in:
arabcoders 2026-01-19 17:15:10 +03:00
parent 57d582e265
commit c33827c6f7
4 changed files with 15 additions and 11 deletions

View file

@ -2,7 +2,7 @@ import asyncio
import datetime
import logging
import uuid
from collections.abc import Awaitable
from collections.abc import Callable
from dataclasses import dataclass, field
from typing import Any
@ -198,10 +198,10 @@ class Event:
class EventListener:
def __init__(self, name: str, callback: callable):
def __init__(self, name: str, callback: Callable[..., Any]):
self.name: str = name
"The name of the listener."
self.call_back: callable = callback
self.call_back: Callable[..., Any] = callback
"The callback function to call when the event is emitted."
self.is_coroutine: bool = asyncio.iscoroutinefunction(callback)
"Whether the callback is a coroutine function or not."
@ -225,7 +225,7 @@ class EventBus(metaclass=Singleton):
self.debug: bool = False
"Whether to log debug messages or not."
self._offload: BackgroundWorker = None
self._offload: BackgroundWorker | None = None
"The background worker to offload tasks to."
@staticmethod
@ -239,7 +239,7 @@ class EventBus(metaclass=Singleton):
"""
return EventBus()
def subscribe(self, event: str | list | tuple, callback: Awaitable, name: str | None = None) -> "EventBus":
def subscribe(self, event: str | list | tuple, callback: Callable[..., Any], name: str | None = None) -> "EventBus":
"""
Subscribe to an event.

View file

@ -19,7 +19,7 @@ class Scheduler(metaclass=Singleton):
self._jobs: dict[str, Cron] = {}
"The scheduled jobs."
self._loop = loop or asyncio.get_event_loop()
self._loop: asyncio.AbstractEventLoop | None = loop
"The event loop to use."
@staticmethod
@ -114,6 +114,13 @@ class Scheduler(metaclass=Singleton):
if id and id in self._jobs:
self.remove(id)
if not self._loop:
try:
self._loop = asyncio.get_running_loop()
except RuntimeError:
self._loop = asyncio.new_event_loop()
asyncio.set_event_loop(self._loop)
job = Cron(spec=timer, func=func, args=args, kwargs=kwargs, uuid=id, start=True, loop=self._loop)
job_id = str(job.uuid)

View file

@ -1,7 +1,7 @@
import asyncio
import logging
import re
from typing import TYPE_CHECKING
from typing import Any
from aiohttp import web
@ -13,9 +13,6 @@ from .Scheduler import Scheduler
from .Singleton import Singleton
from .version import APP_VERSION
if TYPE_CHECKING:
from app.library.dl_fields import Any
LOG: logging.Logger = logging.getLogger("update_checker")

View file

@ -39,7 +39,7 @@
import type { ModelRef } from 'vue';
import type { DLFieldType } from '~/types/dl_fields';
defineProps<{
id: string,
id: number|string,
label: string,
field?: string,
type: DLFieldType,