summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2022-12-23 10:06:24 -0800
committerHarmen Stoppels <harmenstoppels@gmail.com>2022-12-26 22:28:44 +0100
commitd100ac892352e3b63b1fe028207c72fc9a852724 (patch)
tree332a69cb7ac24c09049316c975f7f70178a240bd /lib
parente8fa8c5f0171366f7f2a5cfb3176e42ccf17b6be (diff)
downloadspack-d100ac892352e3b63b1fe028207c72fc9a852724.tar.gz
spack-d100ac892352e3b63b1fe028207c72fc9a852724.tar.bz2
spack-d100ac892352e3b63b1fe028207c72fc9a852724.tar.xz
spack-d100ac892352e3b63b1fe028207c72fc9a852724.zip
types: fix type annotations and remove novm annootations for llnl module
Apparently I forgot to do this in #34305.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/llnl/util/lang.py25
-rw-r--r--lib/spack/llnl/util/tty/log.py6
2 files changed, 13 insertions, 18 deletions
diff --git a/lib/spack/llnl/util/lang.py b/lib/spack/llnl/util/lang.py
index 6cffcd1438..e4140948d8 100644
--- a/lib/spack/llnl/util/lang.py
+++ b/lib/spack/llnl/util/lang.py
@@ -890,8 +890,8 @@ def load_module_from_file(module_name, module_path):
# This recipe is adapted from https://stackoverflow.com/a/67692/771663
- spec = importlib.util.spec_from_file_location(module_name, module_path) # novm
- module = importlib.util.module_from_spec(spec) # novm
+ spec = importlib.util.spec_from_file_location(module_name, module_path)
+ module = importlib.util.module_from_spec(spec)
# The module object needs to exist in sys.modules before the
# loader executes the module code.
#
@@ -990,10 +990,9 @@ def enum(**kwargs):
def stable_partition(
- input_iterable, # type: Iterable
- predicate_fn, # type: Callable[[Any], bool]
-):
- # type: (...) -> Tuple[List[Any], List[Any]]
+ input_iterable: Iterable,
+ predicate_fn: Callable[[Any], bool],
+) -> Tuple[List[Any], List[Any]]:
"""Partition the input iterable according to a custom predicate.
Args:
@@ -1065,23 +1064,20 @@ class GroupedExceptionHandler(object):
"""A generic mechanism to coalesce multiple exceptions and preserve tracebacks."""
def __init__(self):
- self.exceptions = [] # type: List[Tuple[str, Exception, List[str]]]
+ self.exceptions: List[Tuple[str, Exception, List[str]]] = []
def __bool__(self):
"""Whether any exceptions were handled."""
return bool(self.exceptions)
- def forward(self, context):
- # type: (str) -> GroupedExceptionForwarder
+ def forward(self, context: str) -> "GroupedExceptionForwarder":
"""Return a contextmanager which extracts tracebacks and prefixes a message."""
return GroupedExceptionForwarder(context, self)
- def _receive_forwarded(self, context, exc, tb):
- # type: (str, Exception, List[str]) -> None
+ def _receive_forwarded(self, context: str, exc: Exception, tb: List[str]):
self.exceptions.append((context, exc, tb))
- def grouped_message(self, with_tracebacks=True):
- # type: (bool) -> str
+ def grouped_message(self, with_tracebacks: bool = True) -> str:
"""Print out an error message coalescing all the forwarded errors."""
each_exception_message = [
"{0} raised {1}: {2}{3}".format(
@@ -1099,8 +1095,7 @@ class GroupedExceptionForwarder(object):
"""A contextmanager to capture exceptions and forward them to a
GroupedExceptionHandler."""
- def __init__(self, context, handler):
- # type: (str, GroupedExceptionHandler) -> None
+ def __init__(self, context: str, handler: GroupedExceptionHandler):
self._context = context
self._handler = handler
diff --git a/lib/spack/llnl/util/tty/log.py b/lib/spack/llnl/util/tty/log.py
index 0b79dd01ac..008396dbe2 100644
--- a/lib/spack/llnl/util/tty/log.py
+++ b/lib/spack/llnl/util/tty/log.py
@@ -21,12 +21,12 @@ import threading
import traceback
from contextlib import contextmanager
from threading import Thread
-from types import ModuleType # novm
-from typing import Optional # novm
+from types import ModuleType
+from typing import Optional
import llnl.util.tty as tty
-termios = None # type: Optional[ModuleType]
+termios: Optional[ModuleType] = None
try:
import termios as term_mod