From: Scott Gasch Date: Tue, 9 May 2023 04:23:49 +0000 (-0700) Subject: Improve type hints. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=893c5ffcf546cfecc926d701741b76b0a5aa59b1;p=pyutils.git Improve type hints. --- diff --git a/src/pyutils/bootstrap.py b/src/pyutils/bootstrap.py index f096add..7ef7ef1 100644 --- a/src/pyutils/bootstrap.py +++ b/src/pyutils/bootstrap.py @@ -45,6 +45,7 @@ import os import sys import uuid from inspect import stack +from typing import NoReturn from pyutils import config, logging_utils from pyutils.argparse_utils import ActionNoYes @@ -178,7 +179,7 @@ class ImportInterceptor(importlib.abc.MetaPathFinder): def should_ignore_filename(filename: str) -> bool: return "importlib" in filename or "six.py" in filename - def find_module(self, fullname, path): + def find_module(self, fullname, path) -> NoReturn: raise Exception( "This method has been deprecated since Python 3.4, please upgrade." ) diff --git a/src/pyutils/config.py b/src/pyutils/config.py index 9655f25..456be3e 100644 --- a/src/pyutils/config.py +++ b/src/pyutils/config.py @@ -410,7 +410,7 @@ class Config: """ return in_str.lower() in {"true", "1", "yes", "y", "t", "on"} - def _process_dynamic_args(self, event): + def _process_dynamic_args(self, event) -> None: """Invoked as a callback when a zk-based config changed.""" if not self.zk: diff --git a/src/pyutils/decorator_utils.py b/src/pyutils/decorator_utils.py index 1a429cf..f085697 100644 --- a/src/pyutils/decorator_utils.py +++ b/src/pyutils/decorator_utils.py @@ -18,7 +18,7 @@ import threading import time import traceback import warnings -from typing import Any, Callable, List, Optional, Union +from typing import Any, Callable, List, NoReturn, Optional, Union # This module is commonly used by others in here and should avoid # taking any unnecessary dependencies back on them. @@ -706,7 +706,7 @@ def thunkify(func): # to be bound by the terms and conditions of this License Agreement. -def _raise_exception(exception, error_message: Optional[str]): +def _raise_exception(exception, error_message: Optional[str]) -> NoReturn: """Internal. Raise a deferred exception""" if error_message is None: raise Exception(exception)