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
11 changes: 9 additions & 2 deletions challenges/extreme-concatenate/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@
to transform `foo` into the function you want.
"""

from typing import Concatenate, Callable, Any
from typing import Concatenate, Callable, Any, Protocol


class Person:
pass


def transform[T, **P](f: Callable[Concatenate[Any, P], T]):
# Not required to pass the tests
class Transformed[T, **P](Protocol):
def __call__(self, value: Person, *args: P.args, **kwargs: P.kwargs) -> T:
...


# Omitting the return type still passes tests
def transform[T, **P](f: Callable[Concatenate[Any, P], T]) -> Transformed[T, P]:
def wrapper(value: Person, *args: P.args, **kwargs: P.kwargs) -> T:
return f(value, *args, **kwargs)

Expand Down
Loading