diff --git a/pyobs/application.py b/pyobs/application.py index 3a6eb09e..408ecff4 100644 --- a/pyobs/application.py +++ b/pyobs/application.py @@ -6,7 +6,7 @@ import threading from io import StringIO from logging.handlers import TimedRotatingFileHandler -from typing import Optional, Any, Dict +from typing import Optional, Any, Dict, List import yaml from pyobs.object import get_object, get_class_from_string @@ -35,7 +35,7 @@ def __init__(self, config: str, log_file: Optional[str] = None, log_level: str = # formatter for logging, and list of logging handlers formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(filename)s:%(lineno)d %(message)s") - handlers = [] + handlers: List[logging.Handler] = [] # create stdout logging handler stream_handler = logging.StreamHandler() @@ -110,7 +110,7 @@ def run(self) -> None: log.info("Closing loop...") self._loop.close() - def _signal_handler(self, sig) -> None: + def _signal_handler(self, sig: int) -> None: """React to signals and quit module.""" # stop loop diff --git a/pyobs/cli/pyobs.py b/pyobs/cli/pyobs.py index fe99ce24..dd1513ea 100755 --- a/pyobs/cli/pyobs.py +++ b/pyobs/cli/pyobs.py @@ -1,11 +1,14 @@ import argparse import os -from typing import Type, Any +from typing import Type, Any, Optional, TYPE_CHECKING + +if TYPE_CHECKING: + from pyobs.application import Application from pyobs import version -def init_cli(): +def init_cli() -> argparse.ArgumentParser: # init argument parsing # for all command line parameters we set the default to an environment variable, # so they can also be specified that way @@ -30,7 +33,7 @@ def init_cli(): return parser -def parse_cli(parser: argparse.ArgumentParser): +def parse_cli(parser: argparse.ArgumentParser) -> dict[str, Any]: from pyobs.utils.time import Time # parse args @@ -50,7 +53,7 @@ def parse_cli(parser: argparse.ArgumentParser): return vars(args) -def start_daemon(app_class, pid_file=None, **kwargs: Any) -> None: +def start_daemon(app_class: Type["Application"], pid_file: str, **kwargs: Any) -> None: """Start process as a daemon. Args: @@ -70,7 +73,7 @@ def start_daemon(app_class, pid_file=None, **kwargs: Any) -> None: run(app_class, **kwargs) -def run(app_class: Type, **kwargs: Any) -> None: +def run(app_class: Type["Application"], **kwargs: Any) -> None: """Run a pyobs application with the given options. Args: diff --git a/pyobs/cli/pyobsw.py b/pyobs/cli/pyobsw.py index 815d726b..a9c9748c 100644 --- a/pyobs/cli/pyobsw.py +++ b/pyobs/cli/pyobsw.py @@ -1,7 +1,7 @@ from .pyobs import init_cli, parse_cli, run -def main(): +def main() -> None: from pyobs.application import GuiApplication # init argument parsing and parse it