Skip to content

Commit 0fa2d80

Browse files
committed
Improve the question of advanced-typeguard, fixed #99
1 parent ebd195a commit 0fa2d80

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

challenges/advanced-typeguard/question.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
"""
22
TODO:
33
4-
is_string is a function that takes an argument value of arbitrary type, and returns a boolean.
5-
You should make is_string be able to narrow the type of the argument based on its return value:
6-
when it's true, narrow value's type to str.
7-
Basically, it should work like `isinstance(value, str)` from the perspective of a type checker.
4+
`is_string` determines whether the input value is a string.
5+
Your job is to make the type checker be aware of this information.
86
"""
97
from typing import Any
108

119

1210
def is_string(value: Any):
13-
...
11+
return isinstance(value, str)
1412

1513

1614
## End of your code ##

challenges/advanced-typeguard/solution.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""
22
TODO:
33
4-
is_string is a function that takes an argument value of arbitrary type, and returns a boolean.
5-
You should make is_string be able to narrow the type of the argument based on its return value:
6-
when it's true, narrow value's type to str.
7-
Basically, it should work like `isinstance(value, str)` from the perspective of a type checker.
4+
`is_string` determines whether the input value is a string.
5+
Your job is to make the type checker be aware of this information.
86
"""
97
from typing import Any, TypeGuard
108

challenges/extreme-self-casting/solution.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
from typing import Callable, Concatenate, Generic, ParamSpec, TypeVar
1414

1515

16-
R = TypeVar('R')
17-
P = ParamSpec('P')
16+
R = TypeVar("R")
17+
P = ParamSpec("P")
1818

1919

2020
class Fn(Generic[R, P]):

0 commit comments

Comments
 (0)