From b82e9da08e7e01eedcc064e03369ce65f214e557 Mon Sep 17 00:00:00 2001 From: Adam Novak Date: Sat, 16 Dec 2023 03:09:56 -0500 Subject: [PATCH] Make export function preserve types (#666) #665 Co-authored-by: Mike Lin --- WDL/_util.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/WDL/_util.py b/WDL/_util.py index 1affe49a..c7be2ffb 100644 --- a/WDL/_util.py +++ b/WDL/_util.py @@ -32,11 +32,13 @@ from types import FrameType from pythonjsonlogger import jsonlogger +T = TypeVar("T") + __all__: List[str] = [] -def export(obj) -> str: # pyre-ignore - __all__.append(obj.__name__) +def export(obj: T) -> T: + __all__.append(obj.__name__) # pyre-ignore return obj @@ -67,9 +69,6 @@ def strip_leading_whitespace(txt: str) -> Tuple[int, str]: return (to_strip, "\n".join(lines)) -T = TypeVar("T") - - @export class AdjM(Generic[T]): # A sparse adjacency matrix for topological sorting