Skip to content

Commit

Permalink
F-strings doesn't contain bytes literal for PLW0129 (#8675)
Browse files Browse the repository at this point in the history
For the `PLW0129` rule, the f-string case shouldn't match against bytes
literal as f-strings cannot contain them. F-strings are made up of
either string literals or formatted expressions.
  • Loading branch information
dhruvmanila authored Nov 14, 2023
1 parent f7d249a commit 4099b96
Showing 1 changed file with 0 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,13 @@ pub(crate) fn assert_on_string_literal(checker: &mut Checker, test: &Expr) {
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
value.is_empty()
}
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => value.is_empty(),
_ => false,
}) {
Kind::Empty
} else if values.iter().any(|value| match value {
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
!value.is_empty()
}
Expr::BytesLiteral(ast::ExprBytesLiteral { value, .. }) => {
!value.is_empty()
}
_ => false,
}) {
Kind::NonEmpty
Expand Down

0 comments on commit 4099b96

Please sign in to comment.