Skip to content

update extreme-self-casting to not require annotating self #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion challenges/extreme-self-casting/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def transform_callable(self):


## End of your code ##
from typing import assert_type
from typing import assert_type, Any


@Fn
Expand Down
18 changes: 8 additions & 10 deletions challenges/extreme-self-casting/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@
"""


from typing import Callable, Concatenate, ParamSpec, TypeVar, Generic, Any
from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar

P = ParamSpec("P")
R = TypeVar("R", covariant=True)
VnCallable = TypeVar("VnCallable", bound=Callable)

R = TypeVar('R')
P = ParamSpec('P')

class Fn(Generic[VnCallable]):
def __init__(self, f: VnCallable) -> None:

class Fn(Generic[R, P]):
def __init__(self, f: Callable[P, R]):
self.f = f

def transform_callable(
self: "Fn[Callable[P, R]]",
) -> Callable[Concatenate[Any, P], R]:
def transform_callable(self) -> Callable[Concatenate[object, P], R]:
...


## End of your code ##
from typing import assert_type
from typing import assert_type, Any


@Fn
Expand Down
2 changes: 1 addition & 1 deletion challenges/extreme-self-casting/solution2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def transform_callable(self) -> Callable[Concatenate[Any, P], R]:


## End of your code ##
from typing import assert_type
from typing import assert_type, Any


@Fn
Expand Down