Skip to content

Commit ebd195a

Browse files
authored
update extreme-self-casting to not require annotating self (#101)
* 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
1 parent 1e6e332 commit ebd195a

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

challenges/extreme-self-casting/question.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def transform_callable(self):
1919

2020

2121
## End of your code ##
22-
from typing import assert_type
22+
from typing import assert_type, Any
2323

2424

2525
@Fn

challenges/extreme-self-casting/solution.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,23 @@
1010
"""
1111

1212

13-
from typing import Callable, Concatenate, ParamSpec, TypeVar, Generic, Any
13+
from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar
1414

15-
P = ParamSpec("P")
16-
R = TypeVar("R", covariant=True)
17-
VnCallable = TypeVar("VnCallable", bound=Callable)
1815

16+
R = TypeVar('R')
17+
P = ParamSpec('P')
1918

20-
class Fn(Generic[VnCallable]):
21-
def __init__(self, f: VnCallable) -> None:
19+
20+
class Fn(Generic[R, P]):
21+
def __init__(self, f: Callable[P, R]):
2222
self.f = f
2323

24-
def transform_callable(
25-
self: "Fn[Callable[P, R]]",
26-
) -> Callable[Concatenate[Any, P], R]:
24+
def transform_callable(self) -> Callable[Concatenate[object, P], R]:
2725
...
2826

2927

3028
## End of your code ##
31-
from typing import assert_type
29+
from typing import assert_type, Any
3230

3331

3432
@Fn

challenges/extreme-self-casting/solution2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def transform_callable(self) -> Callable[Concatenate[Any, P], R]:
2222

2323

2424
## End of your code ##
25-
from typing import assert_type
25+
from typing import assert_type, Any
2626

2727

2828
@Fn

0 commit comments

Comments
 (0)