mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00
[red-knot] Allow calling bool()
with no arguments (#13568)
This commit is contained in:
parent
d9267132d6
commit
5f4b282327
2 changed files with 4 additions and 3 deletions
|
@ -594,9 +594,8 @@ impl<'db> Type<'db> {
|
||||||
CallOutcome::callable(if is_bool {
|
CallOutcome::callable(if is_bool {
|
||||||
arg_types
|
arg_types
|
||||||
.first()
|
.first()
|
||||||
.unwrap_or(&Type::Unknown)
|
.map(|arg| arg.bool(db).into_type(db))
|
||||||
.bool(db)
|
.unwrap_or(Type::BooleanLiteral(false))
|
||||||
.into_type(db)
|
|
||||||
} else {
|
} else {
|
||||||
Type::Instance(class)
|
Type::Instance(class)
|
||||||
})
|
})
|
||||||
|
|
|
@ -6494,6 +6494,7 @@ mod tests {
|
||||||
c = bool(None)
|
c = bool(None)
|
||||||
d = bool("")
|
d = bool("")
|
||||||
e = bool(False)
|
e = bool(False)
|
||||||
|
f = bool()
|
||||||
"#,
|
"#,
|
||||||
)?;
|
)?;
|
||||||
assert_public_ty(&db, "/src/a.py", "a", "Literal[False]");
|
assert_public_ty(&db, "/src/a.py", "a", "Literal[False]");
|
||||||
|
@ -6501,6 +6502,7 @@ mod tests {
|
||||||
assert_public_ty(&db, "/src/a.py", "c", "Literal[False]");
|
assert_public_ty(&db, "/src/a.py", "c", "Literal[False]");
|
||||||
assert_public_ty(&db, "/src/a.py", "d", "Literal[False]");
|
assert_public_ty(&db, "/src/a.py", "d", "Literal[False]");
|
||||||
assert_public_ty(&db, "/src/a.py", "e", "Literal[False]");
|
assert_public_ty(&db, "/src/a.py", "e", "Literal[False]");
|
||||||
|
assert_public_ty(&db, "/src/a.py", "f", "Literal[False]");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue