Skip to content

Commit

Permalink
fix(typing): improve code to get rid of codeql py/mixed-returns
Browse files Browse the repository at this point in the history
  • Loading branch information
qkaiser committed Dec 24, 2023
1 parent c89d910 commit dcc5ccb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions unblob/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion unblob/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion unblob/signals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import signal
from typing import Callable

from structlog import get_logger

Expand All @@ -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):
Expand Down

0 comments on commit dcc5ccb

Please sign in to comment.