From 61948a8bb4c1ecea489e58c775980f7b60bc7066 Mon Sep 17 00:00:00 2001 From: Phil Weir Date: Mon, 14 Oct 2024 11:43:59 +0200 Subject: [PATCH] fix: typehinting in pycharm - workaround for https://youtrack.jetbrains.com/issue/PY-59108/No-type-check-highlighting-for-imported-decorator --- src/dewret/tasks.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/dewret/tasks.py b/src/dewret/tasks.py index 5786027c..f24314bd 100644 --- a/src/dewret/tasks.py +++ b/src/dewret/tasks.py @@ -72,7 +72,7 @@ Param = ParamSpec("Param") RetType = TypeVar("RetType") - +T = TypeVar("T") class Backend(Enum): """Stringy enum representing available backends.""" @@ -315,6 +315,9 @@ def factory(fn: Callable[..., RetType]) -> Callable[..., RetType]: """ return task(is_factory=True)(fn) +# Workaround for PyCharm +factory: Callable[[Callable[..., RetType]], Callable[..., RetType]] = factory + def workflow() -> Callable[[Callable[Param, RetType]], Callable[Param, RetType]]: """Shortcut for marking a task as nested. @@ -343,6 +346,9 @@ def workflow() -> Callable[[Callable[Param, RetType]], Callable[Param, RetType]] """ return task(nested=True, flatten_nested=False) +# Workaround for PyCharm +workflow: Callable[[], Callable[[T], T]] = workflow + def task( nested: bool = False, @@ -611,6 +617,8 @@ def {fn.__name__}(...) -> ...: return _task +# Workaround for PyCharm +task: Callable[[], Callable[[T], T]] = task def set_backend(backend: Backend) -> None: """Choose a backend.