MCPcopy Create free account
hub / github.com/astral-sh/ruff / round_trip_with

Function round_trip_with

crates/ruff_python_codegen/src/generator.rs:1646–1656  ·  view source on GitHub ↗

Like [`round_trip`] but configure the [`Generator`] with the requested `indentation`, `line_ending` and `unparse_mode` settings.

(
        indentation: &Indentation,
        line_ending: LineEnding,
        unparse_mode: UnparseMode,
        contents: &str,
    )

Source from the content-addressed store, hash-verified

1644 /// Like [`round_trip`] but configure the [`Generator`] with the requested
1645 /// `indentation`, `line_ending` and `unparse_mode` settings.
1646 fn round_trip_with(
1647 indentation: &Indentation,
1648 line_ending: LineEnding,
1649 unparse_mode: UnparseMode,
1650 contents: &str,
1651 ) -> String {
1652 let module = parse_module(contents).unwrap();
1653 let mut generator = Generator::new(indentation, line_ending).with_mode(unparse_mode);
1654 generator.unparse_suite(module.suite());
1655 generator.generate()
1656 }
1657
1658 fn jupyter_round_trip(contents: &str) -> String {
1659 let indentation = Indentation::default();

Callers 2

ast_unparse_quoteFunction · 0.85
ast_tuple_parenthesesFunction · 0.85

Calls 5

parse_moduleFunction · 0.85
unparse_suiteMethod · 0.80
suiteMethod · 0.80
generateMethod · 0.80
with_modeMethod · 0.45

Tested by

no test coverage detected