|
37 | 37 | WHITESPACE, |
38 | 38 | Visitor, |
39 | 39 | ensure_visible, |
| 40 | + fstring_to_string, |
40 | 41 | get_annotation_type, |
41 | 42 | is_arith_like, |
42 | 43 | is_async_stmt_or_funcdef, |
@@ -504,7 +505,7 @@ def visit_NUMBER(self, leaf: Leaf) -> Iterator[Line]: |
504 | 505 |
|
505 | 506 | def visit_fstring(self, node: Node) -> Iterator[Line]: |
506 | 507 | # currently we don't want to format and split f-strings at all. |
507 | | - string_leaf = _fstring_to_string(node) |
| 508 | + string_leaf = fstring_to_string(node) |
508 | 509 | node.replace(string_leaf) |
509 | 510 | yield from self.visit_STRING(string_leaf) |
510 | 511 |
|
@@ -574,12 +575,6 @@ def __post_init__(self) -> None: |
574 | 575 | self.visit_guard = partial(v, keywords=Ø, parens={"if"}) |
575 | 576 |
|
576 | 577 |
|
577 | | -def _fstring_to_string(node: Node) -> Leaf: |
578 | | - """Converts an fstring node back to a string node.""" |
579 | | - string_without_prefix = str(node)[len(node.prefix) :] |
580 | | - return Leaf(token.STRING, string_without_prefix, prefix=node.prefix) |
581 | | - |
582 | | - |
583 | 578 | def _hugging_power_ops_line_to_string( |
584 | 579 | line: Line, |
585 | 580 | features: Collection[Feature], |
@@ -1421,7 +1416,7 @@ def normalize_invisible_parens( # noqa: C901 |
1421 | 1416 | # of case will be not parsed as a Python keyword. |
1422 | 1417 | break |
1423 | 1418 |
|
1424 | | - elif not (isinstance(child, Leaf) and is_multiline_string(child)): |
| 1419 | + elif not is_multiline_string(child): |
1425 | 1420 | wrap_in_parentheses(node, child, visible=False) |
1426 | 1421 |
|
1427 | 1422 | comma_check = child.type == token.COMMA |
|
0 commit comments