Skip to content

Commit

Permalink
Fix type hints for autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhammerl committed Jul 30, 2024
1 parent b59d451 commit 484b52c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions resultify/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from time import sleep
from functools import wraps
from typing import Any, Generic, TypeVar, Union, Type, Callable
from typing import Any, Generic, ParamSpec, TypeVar, Union, Type, Callable

T = TypeVar("T", bound=Any) # Success type
E = TypeVar("E", bound=Exception) # Error type

P = ParamSpec("P")

class Ok(Generic[T]):
"""
Expand Down Expand Up @@ -104,8 +104,8 @@ def __init__(self, message: str) -> None:
super().__init__(message)


def resultify(*errors: Type[E]):
def decorator(function: Callable[..., T]) -> Callable[..., Union[Ok[T], Err[E]]]:
def resultify(*errors: Type[E]) -> Callable[[Callable[P, T]], Callable[P, Result[T, E]]]:
def decorator(function: Callable[P, T]) -> Callable[P, Result[T, E]]:
@wraps(function)
def inner(*args, **kwargs):
try:
Expand Down

0 comments on commit 484b52c

Please sign in to comment.