diff --git a/src/unparser.rs b/src/unparser.rs index 01b0b58..8b6368f 100644 --- a/src/unparser.rs +++ b/src/unparser.rs @@ -1035,10 +1035,18 @@ impl Unparser { let has_single = escaped_source.contains("'"); let has_double = escaped_source.contains("\""); - let has_single_doc = escaped_source.contains("'''"); - if has_single && has_double && has_single_doc { + + if has_single + && has_double + && escaped_source.starts_with("\"") + && escaped_source.ends_with("\"") + { escaped_source = replace_first_and_last(&escaped_source, "\"\"\"") - } else if has_single && has_double { + } else if has_single + && has_double + && escaped_source.starts_with("'") + && escaped_source.ends_with("'") + { escaped_source = replace_first_and_last(&escaped_source, "'''") } else if has_single { escaped_source = replace_first_and_last(&escaped_source, "\"") diff --git a/test_files/f_string.py b/test_files/f_string.py index 8a4bb93..9bf4ea8 100644 --- a/test_files/f_string.py +++ b/test_files/f_string.py @@ -19,4 +19,7 @@ for (k, v) in attribs.items() # noqa ) ) + +completion_init_lines = [f"source '{completion_path}'"] # noqa + # fmt: on