Skip to content

Commit

Permalink
fix: typehinting in pycharm - workaround for https://youtrack.jetbrai…
Browse files Browse the repository at this point in the history
  • Loading branch information
philtweir committed Oct 18, 2024
1 parent b2164a1 commit b12c460
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/dewret/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

Param = ParamSpec("Param")
RetType = TypeVar("RetType")

T = TypeVar("T")

class Backend(Enum):
"""Stringy enum representing available backends."""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b12c460

Please sign in to comment.