mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 23:54:36 -05: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:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user