(
source: str,
expected: Optional[str] = None,
mode: black.Mode = DEFAULT_MODE,
*,
fast: bool = False,
minimum_version: Optional[Tuple[int, int]] = None,
)
| 112 | |
| 113 | |
| 114 | def _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 | |
| 137 | def dump_to_stderr(*output: str) -> str: |
no test coverage detected