Skip to content

Commit b0d65d5

Browse files
committed
add some checks for all this
1 parent b44f182 commit b0d65d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing_extensions import Literal, assert_type
2+
3+
4+
assert_type(bool(), Literal[False])
5+
assert_type(bool(False), Literal[False])
6+
assert_type(bool(True), Literal[True])
7+
assert_type(bool(42), bool)
8+
9+
10+
class Truthy:
11+
def __bool__(self) -> Literal[True]:
12+
return True
13+
14+
15+
class Falsy:
16+
def __bool__(self) -> Literal[False]:
17+
return False
18+
19+
20+
assert_type(bool(Truthy()), Literal[True])
21+
assert_type(bool(Falsy()), Literal[False])

0 commit comments

Comments
 (0)