diff --git a/dashboard.py b/dashboard.py index 076398c8..9010e1b8 100644 --- a/dashboard.py +++ b/dashboard.py @@ -7,7 +7,7 @@ import time import tkinter as tk from calendar import timegm from os.path import getsize, isdir, isfile -from typing import Any, Dict +from typing import Any, Dict, Optional from config import config from EDMCLogging import get_main_logger @@ -37,7 +37,7 @@ class Dashboard(FileSystemEventHandler): self.session_start: int = int(time.time()) self.root: tk.Tk = None # type: ignore self.currentdir: str = None # type: ignore # The actual logdir that we're monitoring - self.observer: Observer = None # type: ignore + self.observer: Optional[Observer] = None # type: ignore self.observed = None # a watchdog ObservedWatch, or None if polling self.status: Dict[str, Any] = {} # Current status for communicating status back to main thread diff --git a/monitor.py b/monitor.py index 15cd72c4..bbbfc190 100644 --- a/monitor.py +++ b/monitor.py @@ -43,6 +43,7 @@ if sys.platform == 'darwin': from AppKit import NSWorkspace from watchdog.events import FileSystemEventHandler from watchdog.observers import Observer + from watchdog.observers.api import BaseObserver F_GLOBAL_NOCACHE = 55 elif sys.platform == 'win32': @@ -51,6 +52,7 @@ elif sys.platform == 'win32': from watchdog.events import FileCreatedEvent, FileSystemEventHandler from watchdog.observers import Observer + from watchdog.observers.api import BaseObserver EnumWindows = ctypes.windll.user32.EnumWindows EnumWindowsProc = ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM) @@ -70,6 +72,7 @@ else: # this isn't ever used, but this will make type checking happy from watchdog.events import FileCreatedEvent from watchdog.observers import Observer + from watchdog.observers.api import BaseObserver # Journal handler @@ -91,7 +94,7 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.root: 'tkinter.Tk' = None # type: ignore # Don't use Optional[] - mypy thinks no methods self.currentdir: str | None = None # The actual logdir that we're monitoring self.logfile: str | None = None - self.observer: 'Observer' | None = None + self.observer: BaseObserver | None = None self.observed = None # a watchdog ObservedWatch, or None if polling self.thread: threading.Thread | None = None # For communicating journal entries back to main thread