Skip to content

Commit

Permalink
[red-knot] Allow calling bool() with no arguments (#13568)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWaygood authored Sep 30, 2024
1 parent d926713 commit 5f4b282
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,8 @@ impl<'db> Type<'db> {
CallOutcome::callable(if is_bool {
arg_types
.first()
.unwrap_or(&Type::Unknown)
.bool(db)
.into_type(db)
.map(|arg| arg.bool(db).into_type(db))
.unwrap_or(Type::BooleanLiteral(false))
} else {
Type::Instance(class)
})
Expand Down
2 changes: 2 additions & 0 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6494,13 +6494,15 @@ mod tests {
c = bool(None)
d = bool("")
e = bool(False)
f = bool()
"#,
)?;
assert_public_ty(&db, "/src/a.py", "a", "Literal[False]");
assert_public_ty(&db, "/src/a.py", "b", "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", "e", "Literal[False]");
assert_public_ty(&db, "/src/a.py", "f", "Literal[False]");
Ok(())
}

Expand Down

0 comments on commit 5f4b282

Please sign in to comment.