Format ourselves in preview mode (#2889)

This commit is contained in:
Jelle Zijlstra 2022-02-23 18:20:59 -08:00 committed by GitHub
parent 7e2b2d4784
commit 2918ea3b07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -17,7 +17,10 @@ extend-exclude = '''
| profiling
)/
'''
# We use preview style for formatting Black itself. If you
# want stable formatting across releases, you should keep
# this off.
preview = true
# Build system information below.
# NOTE: You don't need this in your own Black configuration.

View File

@ -1358,10 +1358,10 @@ def assert_equivalent(src: str, dst: str) -> None:
src_ast = parse_ast(src)
except Exception as exc:
raise AssertionError(
f"cannot use --safe with this file; failed to parse source file AST: "
"cannot use --safe with this file; failed to parse source file AST: "
f"{exc}\n"
f"This could be caused by running Black with an older Python version "
f"that does not support new syntax used in your source file."
"This could be caused by running Black with an older Python version "
"that does not support new syntax used in your source file."
) from exc
try:
@ -1380,7 +1380,7 @@ def assert_equivalent(src: str, dst: str) -> None:
log = dump_to_file(diff(src_ast_str, dst_ast_str, "src", "dst"))
raise AssertionError(
"INTERNAL ERROR: Black produced code that is not equivalent to the"
f" source. Please report a bug on "
" source. Please report a bug on "
f"https://github.com/psf/black/issues. This diff might be helpful: {log}"
) from None

View File

@ -415,7 +415,7 @@ def test_ipynb_diff_with_change() -> None:
f"--config={EMPTY_CONFIG}",
],
)
expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n" '+print("foo")\n'
expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n+print(\"foo\")\n"
assert expected in result.output
@ -494,7 +494,7 @@ def test_ipynb_flag(tmp_path: pathlib.Path) -> None:
f"--config={EMPTY_CONFIG}",
],
)
expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n" '+print("foo")\n'
expected = "@@ -1,3 +1,3 @@\n %%time\n \n-print('foo')\n+print(\"foo\")\n"
assert expected in result.output