mirror of
https://github.com/astral-sh/ruff
synced 2026-01-08 15:14:19 -05:00
Use truthiness check in auto_attribs detection (#14562)
This commit is contained in:
@@ -1118,6 +1118,8 @@ pub enum Truthiness {
|
||||
Falsey,
|
||||
/// The expression evaluates to a `True`-like value (e.g., `1`, `"foo"`).
|
||||
Truthy,
|
||||
/// The expression evaluates to `None`.
|
||||
None,
|
||||
/// The expression evaluates to an unknown value (e.g., a variable `x` of unknown type).
|
||||
Unknown,
|
||||
}
|
||||
@@ -1173,7 +1175,7 @@ impl Truthiness {
|
||||
Self::False
|
||||
}
|
||||
}
|
||||
Expr::NoneLiteral(_) => Self::Falsey,
|
||||
Expr::NoneLiteral(_) => Self::None,
|
||||
Expr::EllipsisLiteral(_) => Self::Truthy,
|
||||
Expr::FString(f_string) => {
|
||||
if is_empty_f_string(f_string) {
|
||||
@@ -1247,6 +1249,7 @@ impl Truthiness {
|
||||
match self {
|
||||
Self::True | Self::Truthy => Some(true),
|
||||
Self::False | Self::Falsey => Some(false),
|
||||
Self::None => Some(false),
|
||||
Self::Unknown => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user