Skip to content

Commit 727b058

Browse files
committed
chore: format
1 parent e65ab64 commit 727b058

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

challenges/advanced-descriptor-basic/question.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ class Descriptor:
1313
class TestClass:
1414
a = Descriptor()
1515

16+
1617
def descriptor_self(x: Descriptor) -> None:
1718
...
1819

20+
1921
def string_value(x: str) -> None:
2022
...
21-
23+
24+
2225
descriptor_self(TestClass.a)
2326
string_value(TestClass().a)
2427

challenges/advanced-descriptor-basic/solution.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,36 @@
66

77
from typing import overload, Self, Any
88

9+
910
class Descriptor:
1011
@overload
1112
def __get__(self, instance: None, owner: type) -> Self:
1213
...
13-
14+
1415
@overload
1516
def __get__(self, instance: Any, owner: type) -> str:
1617
...
17-
18+
1819
def __get__(self, instance: Any, owner: type) -> Self | str:
1920
if instance is None:
2021
return self
21-
22+
2223
return ""
2324

2425

2526
## End of your code ##
2627
class TestClass:
2728
a = Descriptor()
2829

30+
2931
def descriptor_self(x: Descriptor) -> None:
3032
...
3133

34+
3235
def string_value(x: str) -> None:
3336
...
34-
37+
38+
3539
descriptor_self(TestClass.a)
3640
string_value(TestClass().a)
3741

challenges/advanced-my-method/question.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
T = TypeVar("T")
1010
R = TypeVar("R")
1111

12+
1213
class MyMethod(Generic[T, P, R]):
1314
def __init__(self, func: Callable[Concatenate[T, P], R]) -> None:
1415
self.func = func
15-
16+
1617
def __get__(self, instance, owner) -> None:
1718
return
1819

@@ -23,6 +24,7 @@ class Foo:
2324
def do_something(self, value: int) -> None:
2425
...
2526

27+
2628
foo = Foo()
2729

2830
Foo.do_something(foo, 1111)

challenges/advanced-my-method/solution.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@
99
T = TypeVar("T")
1010
R = TypeVar("R")
1111

12+
1213
class MyMethod(Generic[T, P, R]):
1314
def __init__(self, func: Callable[Concatenate[T, P], R]) -> None:
1415
self.func = func
15-
16+
1617
@overload
1718
def __get__(self, instance: None, owner: type) -> Callable[Concatenate[T, P], R]:
1819
...
19-
20+
2021
@overload
2122
def __get__(self, instance: Any, owner: type) -> Callable[P, R]:
2223
...
23-
24+
2425
def __get__(self, instance: Any | None, owner: type):
2526
if instance is None:
2627
return self.func
2728

2829
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
2930
return self.func(instance, *args, **kwargs)
30-
31+
3132
return wrapper
3233

3334

@@ -37,6 +38,7 @@ class Foo:
3738
def do_something(self, value: int) -> None:
3839
...
3940

41+
4042
foo = Foo()
4143

4244
Foo.do_something(foo, 1111)

challenges/extreme-self-casting/question.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@
99

1010
VnCallable = TypeVar("VnCallable", bound=Callable)
1111

12+
1213
class Fn(Generic[VnCallable]):
1314
def __init__(self, f: VnCallable) -> None:
1415
self.f = f
1516

1617
def into_callable(self) -> None:
1718
...
1819

20+
1921
## End of your code ##
2022
@Fn
2123
def example(a: int, b: str, c: float, *, d: bool = False) -> None:
2224
return
2325

2426

25-
assert_type(example.f(1, "1", 1., d=False), None)
27+
assert_type(example.f(1, "1", 1.0, d=False), None)
2628

2729
a: Any = 11111111
28-
b = example.into_callable()(a, 1, "1", 1., d=False)
30+
b = example.into_callable()(a, 1, "1", 1.0, d=False)
2931
assert_type(b, None)
3032

31-
example.into_callable()(1, "1", 1., d=False) # expect-type-error
33+
example.into_callable()(1, "1", 1.0, d=False) # expect-type-error

challenges/extreme-self-casting/solution.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
R = TypeVar("R", covariant=True)
1212
VnCallable = TypeVar("VnCallable", bound=Callable)
1313

14+
1415
class Fn(Generic[VnCallable]):
1516
def __init__(self, f: VnCallable) -> None:
1617
self.f = f
1718

18-
def into_callable(self: 'Fn[Callable[P, R]]') -> Callable[Concatenate[Any, P], R]:
19+
def into_callable(self: "Fn[Callable[P, R]]") -> Callable[Concatenate[Any, P], R]:
1920
...
2021

22+
2123
## End of your code ##
2224
@Fn
2325
def example(a: int, b: str, c: float, *, d: bool = False) -> None:
2426
return
2527

2628

27-
assert_type(example.f(1, "1", 1., d=False), None)
29+
assert_type(example.f(1, "1", 1.0, d=False), None)
2830

2931
a: Any = 11111111
30-
b = example.into_callable()(a, 1, "1", 1., d=False)
32+
b = example.into_callable()(a, 1, "1", 1.0, d=False)
3133
assert_type(b, None)
3234

33-
example.into_callable()(1, "1", 1., d=False) # expect-type-error
35+
example.into_callable()(1, "1", 1.0, d=False) # expect-type-error

0 commit comments

Comments
 (0)