MCPcopy Create free account
hub / github.com/psf/black / _assert_format_inner

Function _assert_format_inner

tests/util.py:114–134  ·  view source on GitHub ↗
(
    source: str,
    expected: Optional[str] = None,
    mode: black.Mode = DEFAULT_MODE,
    *,
    fast: bool = False,
    minimum_version: Optional[Tuple[int, int]] = None,
)

Source from the content-addressed store, hash-verified

112
113
114def _assert_format_inner(
115 source: str,
116 expected: Optional[str] = None,
117 mode: black.Mode = DEFAULT_MODE,
118 *,
119 fast: bool = False,
120 minimum_version: Optional[Tuple[int, int]] = None,
121) -> None:
122 actual = black.format_str(source, mode=mode)
123 if expected is not None:
124 _assert_format_equal(expected, actual)
125 # It's not useful to run safety checks if we're expecting no changes anyway. The
126 # assertion right above will raise if reality does actually make changes. This just
127 # avoids wasted CPU cycles.
128 if not fast and source != actual:
129 # Unfortunately the AST equivalence check relies on the built-in ast module
130 # being able to parse the code being formatted. This doesn't always work out
131 # when checking modern code on older versions.
132 if minimum_version is None or sys.version_info >= minimum_version:
133 black.assert_equivalent(source, actual)
134 black.assert_stable(source, actual, mode=mode)
135
136
137def dump_to_stderr(*output: str) -> str:

Callers 1

assert_formatFunction · 0.85

Calls 1

_assert_format_equalFunction · 0.85

Tested by

no test coverage detected