diff --git a/tests/test_pool.py b/tests/test_pool.py index c80755c63c..1d90854c09 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -62,7 +62,7 @@ def _callback(pool, result): def test_input_cannot_be_submitted_from_worker(): pool: MultiPool - def submit_task(_): + def submit_task(_) -> Exception | None: nonlocal pool try: pool.submit("this should fail") diff --git a/unblob/finder.py b/unblob/finder.py index 207db18812..b602067792 100644 --- a/unblob/finder.py +++ b/unblob/finder.py @@ -3,7 +3,7 @@ The main "entry point" is search_chunks_by_priority. """ from functools import lru_cache -from typing import List, Optional +from typing import List import attr from pyperscan import Flag, Pattern, Scan, StreamDatabase @@ -29,7 +29,7 @@ class HyperscanMatchContext: def _calculate_chunk( handler: Handler, file: File, real_offset, task_result: TaskResult -) -> Optional[ValidChunk]: +) -> ValidChunk | None: file.seek(real_offset) try: return handler.calculate_chunk(file, real_offset) diff --git a/unblob/processing.py b/unblob/processing.py index 72b500a301..f7eb930cc2 100644 --- a/unblob/processing.py +++ b/unblob/processing.py @@ -362,7 +362,7 @@ def _process_directory(self) -> Tuple[Set[Path], Set[Path]]: @staticmethod def _calculate_multifile( dir_handler: DirectoryHandler, path: Path, task_result: TaskResult - ) -> Optional[MultiFile]: + ) -> MultiFile | None: try: return dir_handler.calculate_multifile(path) except InvalidInputFormat as exc: diff --git a/unblob/signals.py b/unblob/signals.py index 76b70a4dbe..2c4837c96d 100644 --- a/unblob/signals.py +++ b/unblob/signals.py @@ -1,5 +1,6 @@ import functools import signal +from typing import Callable from structlog import get_logger @@ -14,7 +15,7 @@ def __init__(self, signal: str): def terminate_gracefully(func): @functools.wraps(func) - def decorator(*args, **kwargs): + def decorator(*args, **kwargs) -> Callable | None: signals_fired = [] def _handle_signal(signum: int, frame):