Fix typing issues in debug_tools.
This commit is contained in:
@@ -11,9 +11,10 @@ desc: Debugging tools for AuDaGe.
|
|||||||
import time
|
import time
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def print_and_return(value: any) -> any:
|
def print_and_return(value: Any) -> Any:
|
||||||
print(value)
|
print(value)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ def catch(
|
|||||||
*args,
|
*args,
|
||||||
handle: Callable = lambda e: e,
|
handle: Callable = lambda e: e,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> any:
|
) -> Any:
|
||||||
"""Function for catching errors in-line.
|
"""Function for catching errors in-line.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
@@ -48,16 +49,16 @@ def catch(
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except exception as e:
|
except exception as e: # ty: ignore[invalid-exception-caught]
|
||||||
return handle(e)
|
return handle(e)
|
||||||
|
|
||||||
|
|
||||||
class TimeUnit(IntEnum):
|
class TimeUnit(IntEnum):
|
||||||
"""Conversion ratios to/from nanoseconds for various time units."""
|
"""Conversion ratios to/from nanoseconds for various time units."""
|
||||||
|
|
||||||
NS = 1e9
|
NS = 1_000_000_000
|
||||||
US = 1e6
|
US = 1_000_000
|
||||||
MS = 1e3
|
MS = 1_000
|
||||||
S = 1
|
S = 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user