We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b44f182 commit b0d65d5Copy full SHA for b0d65d5
stdlib/@tests/test_cases/builtins/check_bool.py
@@ -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