From 25f1b49c35729d402d1adb1976c803381cd9c1cd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Jan 2024 12:41:16 -0500 Subject: [PATCH 1/4] update extreme-self-casting to not require annotating `self` --- challenges/extreme-self-casting/solution.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/challenges/extreme-self-casting/solution.py b/challenges/extreme-self-casting/solution.py index 5fa7d26..5e589b5 100644 --- a/challenges/extreme-self-casting/solution.py +++ b/challenges/extreme-self-casting/solution.py @@ -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 From 5522af1800e887f829489a9d77d911b13b6e2db9 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Jan 2024 12:45:15 -0500 Subject: [PATCH 2/4] update question code to contain imports it uses --- challenges/extreme-self-casting/question.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/extreme-self-casting/question.py b/challenges/extreme-self-casting/question.py index b1f9373..b8bb43d 100644 --- a/challenges/extreme-self-casting/question.py +++ b/challenges/extreme-self-casting/question.py @@ -19,7 +19,7 @@ def transform_callable(self): ## End of your code ## -from typing import assert_type +from typing import assert_type, Any @Fn From 5e9482dc23f3a2c790d3d96a6150ad0901054f45 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Jan 2024 12:45:38 -0500 Subject: [PATCH 3/4] update question code to contain imports it uses --- challenges/extreme-self-casting/solution2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/extreme-self-casting/solution2.py b/challenges/extreme-self-casting/solution2.py index 8bdeeca..8744a65 100644 --- a/challenges/extreme-self-casting/solution2.py +++ b/challenges/extreme-self-casting/solution2.py @@ -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 From 47bb0fc43f1ca113a4c21bd8dad09c40c46c2821 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Jan 2024 12:49:09 -0500 Subject: [PATCH 4/4] fix copy paste typo --- challenges/extreme-self-casting/solution.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenges/extreme-self-casting/solution.py b/challenges/extreme-self-casting/solution.py index 5e589b5..be906ad 100644 --- a/challenges/extreme-self-casting/solution.py +++ b/challenges/extreme-self-casting/solution.py @@ -10,7 +10,7 @@ """ -from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar, +from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar R = TypeVar('R')