mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 17:41:12 +00:00
Use truthiness check in auto_attribs
detection (#14562)
This commit is contained in:
parent
d285717da8
commit
de62e39eba
7 changed files with 54 additions and 15 deletions
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue