mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 04:55:09 +00:00
Formatter: Better f-string dummy (#5730)
## Summary The previous dummy was causing instabilities since it turned a string into a variable. E.g. ```python script_header_dict[ "slurm_partition_line" ] = f"#SBATCH --partition {resources.queue_name}" ``` has an instability as ```python - script_header_dict["slurm_partition_line"] = ( - NOT_YET_IMPLEMENTED_ExprJoinedStr - ) + script_header_dict[ + "slurm_partition_line" + ] = NOT_YET_IMPLEMENTED_ExprJoinedStr ``` ## Test Plan The instability is gone, otherwise it's still a dummy
This commit is contained in:
parent
e9771c9c63
commit
68e0f97354
13 changed files with 127 additions and 112 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::context::PyFormatContext;
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
||||
use crate::{not_yet_implemented, FormatNodeRule, PyFormatter};
|
||||
use crate::{not_yet_implemented_custom_text, FormatNodeRule, PyFormatter};
|
||||
use ruff_formatter::{write, Buffer, FormatResult};
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use rustpython_parser::ast::ExprJoinedStr;
|
||||
|
@ -9,8 +9,13 @@ use rustpython_parser::ast::ExprJoinedStr;
|
|||
pub struct FormatExprJoinedStr;
|
||||
|
||||
impl FormatNodeRule<ExprJoinedStr> for FormatExprJoinedStr {
|
||||
fn fmt_fields(&self, item: &ExprJoinedStr, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(f, [not_yet_implemented(item)])
|
||||
fn fmt_fields(&self, _item: &ExprJoinedStr, f: &mut PyFormatter) -> FormatResult<()> {
|
||||
write!(
|
||||
f,
|
||||
[not_yet_implemented_custom_text(
|
||||
r#"f"NOT_YET_IMPLEMENTED_ExprJoinedStr""#
|
||||
)]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue