Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions eth_utils/applicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Generator,
List,
Tuple,
TypeVar,
Union,
)
import warnings
Expand All @@ -23,6 +24,9 @@
curry,
)

TArg = TypeVar("TArg")
TReturn = TypeVar("TReturn")

Formatters = Callable[[List[Any]], List[Any]]


Expand Down Expand Up @@ -83,8 +87,8 @@ def apply_formatters_to_sequence(


def apply_formatter_if(
condition: Callable[..., bool], formatter: Callable[..., Any], value: Any
) -> Any:
condition: Callable[[TArg], bool], formatter: Callable[[TArg], TReturn], value: TArg
) -> Union[TArg, TReturn]:
if condition(value):
return formatter(value)
else:
Expand Down Expand Up @@ -131,8 +135,8 @@ def apply_formatters_to_dict(

@return_arg_type(1)
def apply_formatter_to_array(
formatter: Callable[..., Any], value: List[Any]
) -> Generator[List[Any], None, None]:
formatter: Callable[[TArg], TReturn], value: List[TArg]
) -> Generator[TReturn, None, None]:
for item in value:
yield formatter(item)

Expand Down