MCPcopy Index your code
hub / github.com/python/cpython / _write_interpolation

Method _write_interpolation

Lib/_ast_unparse.py:661–675  ·  view source on GitHub ↗
(self, node, use_str_attr=False)

Source from the content-addressed store, hash-verified

659 return unparser.visit(inner)
660
661 def _write_interpolation(self, node, use_str_attr=False):
662 with self.delimit("{", "}"):
663 if use_str_attr:
664 expr = node.str
665 else:
666 expr = self._unparse_interpolation_value(node.value)
667 if expr.startswith("{"):
668 # Separate pair of opening brackets as "{ {"
669 self.write(" ")
670 self.write(expr)
671 if node.conversion != -1:
672 self.write(f"!{chr(node.conversion)}")
673 if node.format_spec:
674 self.write(":")
675 self._write_ftstring_inner(node.format_spec, is_format_spec=True)
676
677 def visit_FormattedValue(self, node):
678 self._write_interpolation(node)

Callers 2

visit_FormattedValueMethod · 0.95
visit_InterpolationMethod · 0.95

Calls 5

delimitMethod · 0.95
writeMethod · 0.95
_write_ftstring_innerMethod · 0.95
startswithMethod · 0.45

Tested by

no test coverage detected