Skip to content

Commit a378ff3

Browse files
authored
[red-knot] Fix Boolean flags in mdtests (#14654)
## Summary Similar to #14652, but now with conditions that are `Literal[True]` (instead of `Literal[False]`), where we want them to be `bool`.
1 parent d8bca0d commit a378ff3

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

crates/red_knot_python_semantic/resources/mdtest/subscript/class.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ reveal_type(Identity[0]) # revealed: str
2121
## Class getitem union
2222

2323
```py
24-
flag = True
24+
def bool_instance() -> bool:
25+
return True
2526

2627
class UnionClassGetItem:
27-
if flag:
28+
if bool_instance():
2829

2930
def __class_getitem__(cls, item: int) -> str:
3031
return item
@@ -59,9 +60,10 @@ reveal_type(x[0]) # revealed: str | int
5960
## Class getitem with unbound method union
6061

6162
```py
62-
flag = True
63+
def bool_instance() -> bool:
64+
return True
6365

64-
if flag:
66+
if bool_instance():
6567
class Spam:
6668
def __class_getitem__(self, x: int) -> str:
6769
return "foo"
@@ -77,9 +79,10 @@ reveal_type(Spam[42])
7779
## TODO: Class getitem non-class union
7880

7981
```py
80-
flag = True
82+
def bool_instance() -> bool:
83+
return True
8184

82-
if flag:
85+
if bool_instance():
8386
class Eggs:
8487
def __class_getitem__(self, x: int) -> str:
8588
return "foo"

crates/red_knot_python_semantic/resources/mdtest/subscript/instance.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ reveal_type(Identity()[0]) # revealed: int
3030
## Getitem union
3131

3232
```py
33-
flag = True
33+
def bool_instance() -> bool:
34+
return True
3435

3536
class Identity:
36-
if flag:
37+
if bool_instance():
3738

3839
def __getitem__(self, index: int) -> int:
3940
return index

0 commit comments

Comments
 (0)