mirror of https://github.com/astral-sh/ruff
Remove unicode flag from comparable (#8440)
## Summary This PR removes the `unicode` flag from the string literal in `ComparableExpr`. This flag isn't required as all strings are unicode in Python 3 so `"foo" == u"foo"`.
This commit is contained in:
parent
a8a72306f0
commit
d350ede992
|
|
@ -649,8 +649,8 @@ pub enum ComparableLiteral<'a> {
|
||||||
None,
|
None,
|
||||||
Ellipsis,
|
Ellipsis,
|
||||||
Bool(&'a bool),
|
Bool(&'a bool),
|
||||||
Str { value: &'a str, unicode: &'a bool },
|
Str(&'a str),
|
||||||
Bytes { value: &'a [u8] },
|
Bytes(&'a [u8]),
|
||||||
Number(ComparableNumber<'a>),
|
Number(ComparableNumber<'a>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -662,13 +662,11 @@ impl<'a> From<ast::LiteralExpressionRef<'a>> for ComparableLiteral<'a> {
|
||||||
ast::LiteralExpressionRef::BooleanLiteral(ast::ExprBooleanLiteral {
|
ast::LiteralExpressionRef::BooleanLiteral(ast::ExprBooleanLiteral {
|
||||||
value, ..
|
value, ..
|
||||||
}) => Self::Bool(value),
|
}) => Self::Bool(value),
|
||||||
ast::LiteralExpressionRef::StringLiteral(ast::ExprStringLiteral {
|
ast::LiteralExpressionRef::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
|
||||||
value,
|
Self::Str(value)
|
||||||
unicode,
|
}
|
||||||
..
|
|
||||||
}) => Self::Str { value, unicode },
|
|
||||||
ast::LiteralExpressionRef::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => {
|
ast::LiteralExpressionRef::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => {
|
||||||
Self::Bytes { value }
|
Self::Bytes(value)
|
||||||
}
|
}
|
||||||
ast::LiteralExpressionRef::NumberLiteral(ast::ExprNumberLiteral { value, .. }) => {
|
ast::LiteralExpressionRef::NumberLiteral(ast::ExprNumberLiteral { value, .. }) => {
|
||||||
Self::Number(value.into())
|
Self::Number(value.into())
|
||||||
|
|
@ -680,7 +678,6 @@ impl<'a> From<ast::LiteralExpressionRef<'a>> for ComparableLiteral<'a> {
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct ExprStringLiteral<'a> {
|
pub struct ExprStringLiteral<'a> {
|
||||||
value: &'a str,
|
value: &'a str,
|
||||||
unicode: &'a bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
|
|
@ -948,9 +945,9 @@ impl<'a> From<&'a ast::Expr> for ComparableExpr<'a> {
|
||||||
// Compare strings based on resolved value, not representation (i.e., ignore whether
|
// Compare strings based on resolved value, not representation (i.e., ignore whether
|
||||||
// the string was implicitly concatenated).
|
// the string was implicitly concatenated).
|
||||||
implicit_concatenated: _,
|
implicit_concatenated: _,
|
||||||
unicode,
|
unicode: _,
|
||||||
range: _,
|
range: _,
|
||||||
}) => Self::StringLiteral(ExprStringLiteral { value, unicode }),
|
}) => Self::StringLiteral(ExprStringLiteral { value }),
|
||||||
ast::Expr::BytesLiteral(ast::ExprBytesLiteral {
|
ast::Expr::BytesLiteral(ast::ExprBytesLiteral {
|
||||||
value,
|
value,
|
||||||
// Compare bytes based on resolved value, not representation (i.e., ignore whether
|
// Compare bytes based on resolved value, not representation (i.e., ignore whether
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue