mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-01 17:32:25 +00:00
[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`.
This commit is contained in:
parent
d8bca0d3a2
commit
a378ff38dc
2 changed files with 12 additions and 8 deletions
|
@ -21,10 +21,11 @@ reveal_type(Identity[0]) # revealed: str
|
|||
## Class getitem union
|
||||
|
||||
```py
|
||||
flag = True
|
||||
def bool_instance() -> bool:
|
||||
return True
|
||||
|
||||
class UnionClassGetItem:
|
||||
if flag:
|
||||
if bool_instance():
|
||||
|
||||
def __class_getitem__(cls, item: int) -> str:
|
||||
return item
|
||||
|
@ -59,9 +60,10 @@ reveal_type(x[0]) # revealed: str | int
|
|||
## Class getitem with unbound method union
|
||||
|
||||
```py
|
||||
flag = True
|
||||
def bool_instance() -> bool:
|
||||
return True
|
||||
|
||||
if flag:
|
||||
if bool_instance():
|
||||
class Spam:
|
||||
def __class_getitem__(self, x: int) -> str:
|
||||
return "foo"
|
||||
|
@ -77,9 +79,10 @@ reveal_type(Spam[42])
|
|||
## TODO: Class getitem non-class union
|
||||
|
||||
```py
|
||||
flag = True
|
||||
def bool_instance() -> bool:
|
||||
return True
|
||||
|
||||
if flag:
|
||||
if bool_instance():
|
||||
class Eggs:
|
||||
def __class_getitem__(self, x: int) -> str:
|
||||
return "foo"
|
||||
|
|
|
@ -30,10 +30,11 @@ reveal_type(Identity()[0]) # revealed: int
|
|||
## Getitem union
|
||||
|
||||
```py
|
||||
flag = True
|
||||
def bool_instance() -> bool:
|
||||
return True
|
||||
|
||||
class Identity:
|
||||
if flag:
|
||||
if bool_instance():
|
||||
|
||||
def __getitem__(self, index: int) -> int:
|
||||
return index
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue