Skip to content

Commit cb6bae8

Browse files
committed
Add challenge
1 parent c0b5073 commit cb6bae8

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class MyClass:
2+
def __init__(self, x: int) -> None:
3+
self.x = x
4+
5+
# TODO: Fix the type hints of `copy` to make it type check
6+
def copy(self) -> MyClass:
7+
copied_object = MyClass(x=self.x)
8+
return copied_object
9+
10+
11+
## End of your code ##
12+
13+
from typing import assert_type
14+
15+
inst = MyClass(x=1)
16+
assert_type(inst.copy(), MyClass)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class MyClass:
2+
def __init__(self, x: int) -> None:
3+
self.x = x
4+
5+
# TODO: Fix the type hints of `copy` to make it type check
6+
def copy(self) -> "MyClass":
7+
copied_object = MyClass(x=self.x)
8+
return copied_object
9+
10+
11+
## End of your code ##
12+
13+
from typing import assert_type
14+
15+
inst = MyClass(x=1)
16+
assert_type(inst.copy(), MyClass)

challenges/advanced-never2/question.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33

44
def stop() -> Never:
55
"""TODO: implement this function to make it type check"""
6+
7+
8+
## End of your code ##
9+
from typing import assert_never
10+
11+
assert_never(stop())

challenges/advanced-never2/solution.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
def stop() -> Never:
55
"""TODO: implement this function to make it type check"""
66
raise RuntimeError("")
7+
8+
9+
## End of your code ##
10+
from typing import assert_never
11+
12+
assert_never(stop())

0 commit comments

Comments
 (0)