Skip to content

Commit 53761e9

Browse files
committed
chore: enhance messages
1 parent 727b058 commit 53761e9

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

challenges/advanced-descriptor-basic/question.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
"""
22
TODO:
33
4-
Define a descriptor, make test case works.
4+
Create a descriptor and adorn the __get__ method with the @typing.overload decorator to ensure the functionality of the test case.
5+
6+
NOTE: Craft at least two overload declarations:
7+
8+
- one to handle the case when the instance is None (i.e., accessing TestClass.a), and another...
9+
- ...to cater to any instance of TestClass.
10+
11+
NOTE: By explicitly binding the instance parameter to the TestClass class, the test cases can also be successfully passed.
512
"""
613

714

815
class Descriptor:
9-
...
16+
def __get__(self, instance: ..., owner: ...):
17+
...
1018

1119

1220
## End of your code ##

challenges/extreme-self-casting/question.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111

1212

1313
class Fn(Generic[VnCallable]):
14+
# you MUST NOT modify the Generic defination.
15+
1416
def __init__(self, f: VnCallable) -> None:
1517
self.f = f
1618

17-
def into_callable(self) -> None:
19+
def into_callable(self):
20+
# TODO: annotate self parameter, not required to touch the function body.
21+
# NOTE: the test case requires a Any prefix param before VnCallable's parameters.
22+
# information is enough for type checker to infer these types.
1823
...
1924

2025

challenges/extreme-self-casting/solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class Fn(Generic[VnCallable]):
1616
def __init__(self, f: VnCallable) -> None:
17-
self.f = f
17+
...
1818

1919
def into_callable(self: "Fn[Callable[P, R]]") -> Callable[Concatenate[Any, P], R]:
2020
...

0 commit comments

Comments
 (0)