From: Scott Gasch Date: Wed, 9 Feb 2022 05:13:09 +0000 (-0800) Subject: Fighting with type hints. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=2e2eab8453f1d7f85236f306283e2987562995d0;p=python_utils.git Fighting with type hints. --- diff --git a/state_tracker.py b/state_tracker.py index b375f89..1cf62af 100644 --- a/state_tracker.py +++ b/state_tracker.py @@ -109,7 +109,7 @@ class AutomaticStateTracker(StateTracker): """ @background_thread - def pace_maker(self, should_terminate) -> None: + def pace_maker(self, should_terminate: threading.Event) -> None: """Entry point for a background thread to own calling heartbeat() at regular intervals so that the main thread doesn't need to do so. diff --git a/thread_utils.py b/thread_utils.py index 4db4cf6..2375f3d 100644 --- a/thread_utils.py +++ b/thread_utils.py @@ -6,7 +6,7 @@ import functools import logging import os import threading -from typing import Callable, Optional, Tuple +from typing import Any, Callable, Optional, Tuple # This module is commonly used by others in here and should avoid # taking any unnecessary dependencies back on them. @@ -62,7 +62,7 @@ def is_current_thread_main_thread() -> bool: def background_thread( - _funct: Optional[Callable], + _funct: Optional[Callable[..., Any]], ) -> Callable[..., Tuple[threading.Thread, threading.Event]]: """A function decorator to create a background thread.