Format bytes string (#6166)

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

Format bytes string

Closes #6064

## Test Plan

Added a fixture based on string's one
This commit is contained in:
Luc Khai Hai 2023-07-31 17:46:40 +09:00 committed by GitHub
parent de898c52eb
commit b95fc6d162
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 577 additions and 89 deletions

View file

@ -31,7 +31,7 @@ pub enum StringLayout {
impl<'a> FormatString<'a> {
pub(super) fn new(constant: &'a ExprConstant) -> Self {
debug_assert!(constant.value.is_str());
debug_assert!(constant.value.is_str() || constant.value.is_bytes());
Self {
constant,
layout: StringLayout::Default,
@ -70,7 +70,7 @@ struct FormatStringContinuation<'a> {
impl<'a> FormatStringContinuation<'a> {
fn new(constant: &'a ExprConstant) -> Self {
debug_assert!(constant.value.is_str());
debug_assert!(constant.value.is_str() || constant.value.is_bytes());
Self { constant }
}
}