Skip to content

Commit e07e790

Browse files
committed
Add new challenges
1 parent 32b5073 commit e07e790

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed

challenges/advanced-never/question.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""
2+
TODO:
3+
4+
Make sure `never_call_me` is never called.
5+
"""
6+
7+
8+
def never_call_me(arg):
9+
pass
10+
11+
12+
## End of your code ##
13+
def int_or_str(arg: int | str) -> None:
14+
never_call_me(arg) # expect-type-error
15+
match arg:
16+
case int():
17+
print("It's an int")
18+
case str():
19+
print("It's a str")
20+
case _:
21+
never_call_me(arg)

challenges/advanced-never/solution.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
TODO:
3+
4+
Make sure `never_call_me` is never called.
5+
"""
6+
from typing import Never
7+
8+
9+
def never_call_me(arg: Never):
10+
pass
11+
12+
13+
## End of your code ##
14+
def int_or_str(arg: int | str) -> None:
15+
never_call_me(arg) # expect-type-error
16+
match arg:
17+
case int():
18+
print("It's an int")
19+
case str():
20+
print("It's a str")
21+
case _:
22+
never_call_me(arg)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from typing import Never
2+
3+
4+
def stop() -> Never:
5+
"""TODO: implement this function to make it type check"""
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from typing import Never
2+
3+
4+
def stop() -> Never:
5+
"""TODO: implement this function to make it type check"""

challenges/basic-final/question.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""
2+
TODO:
3+
4+
Make sure `my_list` cannot be re-assigned to.
5+
"""
6+
7+
8+
my_list = []
9+
10+
## End of your code ##
11+
my_list.append(1)
12+
my_list = [] # expect-type-error
13+
my_list = "something else" # expect-type-error

challenges/basic-final/solution.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
TODO:
3+
4+
Make sure `my_list` cannot be re-assigned to.
5+
"""
6+
7+
from typing import Final
8+
9+
10+
my_list: Final = []
11+
12+
## End of your code ##
13+
my_list.append(1)
14+
my_list = [] # expect-type-error
15+
my_list = "something else" # expect-type-error

0 commit comments

Comments
 (0)