Skip to content

Commit

Permalink
Format ourselves in preview mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Feb 21, 2022
1 parent 50a8569 commit 26a6611
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion pyproject.toml
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/black/__init__.py
Expand Up @@ -1343,10 +1343,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:
Expand All @@ -1365,7 +1365,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

Expand Down
4 changes: 2 additions & 2 deletions tests/test_ipynb.py
Expand Up @@ -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


Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 26a6611

Please sign in to comment.