Skip to content

Commit

Permalink
update extreme-self-casting to not require annotating self (#101)
Browse files Browse the repository at this point in the history
* update extreme-self-casting to not require annotating `self`

* update question code to contain imports it uses

* update question code to contain imports it uses

* fix copy paste typo
  • Loading branch information
asottile committed Jan 23, 2024
1 parent 1e6e332 commit ebd195a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
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

0 comments on commit ebd195a

Please sign in to comment.