mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-10 05:39:12 +00:00
Impl Default
for (String|Bytes|Boolean|None|Ellipsis)Literal
(#8341)
## Summary This PR adds `Default` for the following literal nodes: * `StringLiteral` * `BytesLiteral` * `BooleanLiteral` * `NoneLiteral` * `EllipsisLiteral` The implementation creates the zero value of the respective literal nodes in terms of the Python language. ## Test Plan `cargo test`
This commit is contained in:
parent
b5a4a9a356
commit
b0dc5a86a1
8 changed files with 16 additions and 44 deletions
|
@ -987,7 +987,7 @@ impl From<ExprFString> for Expr {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct ExprStringLiteral {
|
||||
pub range: TextRange,
|
||||
pub value: String,
|
||||
|
@ -1015,7 +1015,7 @@ impl Deref for ExprStringLiteral {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct ExprBytesLiteral {
|
||||
pub range: TextRange,
|
||||
pub value: Vec<u8>,
|
||||
|
@ -1059,7 +1059,7 @@ pub enum Number {
|
|||
Complex { real: f64, imag: f64 },
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct ExprBooleanLiteral {
|
||||
pub range: TextRange,
|
||||
pub value: bool,
|
||||
|
@ -1077,7 +1077,7 @@ impl Ranged for ExprBooleanLiteral {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct ExprNoneLiteral {
|
||||
pub range: TextRange,
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ impl Ranged for ExprNoneLiteral {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct ExprEllipsisLiteral {
|
||||
pub range: TextRange,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue