From 3ae49b46f3a35bc5819ef3ba57d86dbce5a8ccca Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Fri, 18 Jul 2025 01:01:37 -0700 Subject: [PATCH 01/10] Normalize newlines --- src/black/__init__.py | 42 ++++++++++++++++++++++++++++++------------ src/blackd/__init__.py | 8 -------- tests/test_black.py | 23 ++++++++++++++++------- 3 files changed, 46 insertions(+), 27 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 48d2bb8154b..57ea54976d0 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1010,7 +1010,7 @@ def format_stdin_to_stdout( if content is None: src, encoding, newline = decode_bytes(sys.stdin.buffer.read()) else: - src, encoding, newline = content, "utf-8", "" + src, encoding, newline = content, "utf-8", "\n" dst = src try: @@ -1026,11 +1026,11 @@ def format_stdin_to_stdout( ) if write_back == WriteBack.YES: # Make sure there's a newline after the content - if dst and dst[-1] != "\n": - dst += "\n" + if dst and dst[-1] != "\n" and dst[-1] != "\r": + dst += newline f.write(dst) elif write_back in (WriteBack.DIFF, WriteBack.COLOR_DIFF): - now = datetime.now(timezone.utc) + now = datetime.now(tz=timezone.utc) src_name = f"STDIN\t{then}" dst_name = f"STDOUT\t{now}" d = diff(src, dst, src_name, dst_name) @@ -1217,7 +1217,11 @@ def f( def _format_str_once( src_contents: str, *, mode: Mode, lines: Collection[tuple[int, int]] = () ) -> str: - src_node = lib2to3_parse(src_contents.lstrip(), mode.target_versions) + normalized_contents, _, newline_type = decode_bytes(src_contents.encode("utf-8")) + + src_node = lib2to3_parse( + normalized_contents.lstrip(), target_versions=mode.target_versions + ) dst_blocks: list[LinesBlock] = [] if mode.target_versions: versions = mode.target_versions @@ -1259,13 +1263,11 @@ def _format_str_once( for block in dst_blocks: dst_contents.extend(block.all_lines()) if not dst_contents: - # Use decode_bytes to retrieve the correct source newline (CRLF or LF), - # and check if normalized_content has more than one line - normalized_content, _, newline = decode_bytes(src_contents.encode("utf-8")) - if "\n" in normalized_content: - return newline + if "\n" in normalized_contents: + return newline_type return "" - return "".join(dst_contents) + # print(f"{src_contents=}\n{normalized_contents=}\n{newline_type=}\n") + return "".join(dst_contents).replace("\n", newline_type) def decode_bytes(src: bytes) -> tuple[FileContent, Encoding, NewLine]: @@ -1274,12 +1276,28 @@ def decode_bytes(src: bytes) -> tuple[FileContent, Encoding, NewLine]: `newline` is either CRLF or LF but `decoded_contents` is decoded with universal newlines (i.e. only contains LF). """ + # breakpoint() srcbuf = io.BytesIO(src) encoding, lines = tokenize.detect_encoding(srcbuf.readline) if not lines: return "", encoding, "\n" - newline = "\r\n" if lines[0][-2:] == b"\r\n" else "\n" + if lines[0][-2:] == b"\r\n": + if b"\r" in lines[0][:-2]: + newline = "\r" + else: + newline = "\r\n" + elif lines[0][-1:] == b"\n": + if b"\r" in lines[0][:-1]: + newline = "\r" + else: + newline = "\n" + else: + if b"\r" in lines[0]: + newline = "\r" + else: + newline = "\n" + srcbuf.seek(0) with io.TextIOWrapper(srcbuf, encoding) as tiow: return tiow.read(), encoding, newline diff --git a/src/blackd/__init__.py b/src/blackd/__init__.py index 86309da0ef0..432ca81a5ae 100644 --- a/src/blackd/__init__.py +++ b/src/blackd/__init__.py @@ -129,14 +129,6 @@ async def handle(request: web.Request, executor: Executor) -> web.Response: executor, partial(black.format_file_contents, req_str, fast=fast, mode=mode) ) - # Preserve CRLF line endings - nl = req_str.find("\n") - if nl > 0 and req_str[nl - 1] == "\r": - formatted_str = formatted_str.replace("\n", "\r\n") - # If, after swapping line endings, nothing changed, then say so - if formatted_str == req_str: - raise black.NothingChanged - # Put the source first line back req_str = header + req_str formatted_str = header + formatted_str diff --git a/tests/test_black.py b/tests/test_black.py index 98d03652abe..6ceb8fa759e 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -3,6 +3,7 @@ import asyncio import inspect import io +import itertools import logging import multiprocessing import os @@ -2057,17 +2058,17 @@ def test_carriage_return_edge_cases(self) -> None: "try:\\\r# type: ignore\n pass\nfinally:\n pass\n", mode=black.FileMode(), ) - == "try: # type: ignore\n pass\nfinally:\n pass\n" + == "try: # type: ignore\r pass\rfinally:\r pass\r" ) - assert black.format_str("{\r}", mode=black.FileMode()) == "{}\n" - assert black.format_str("pass #\r#\n", mode=black.FileMode()) == "pass #\n#\n" + assert black.format_str("{\r}", mode=black.FileMode()) == "{}\r" + assert black.format_str("pass #\r#\n", mode=black.FileMode()) == "pass #\r#\r" - assert black.format_str("x=\\\r\n1", mode=black.FileMode()) == "x = 1\n" + assert black.format_str("x=\\\r\n1", mode=black.FileMode()) == "x = 1\r\n" assert black.format_str("x=\\\n1", mode=black.FileMode()) == "x = 1\n" - assert black.format_str("x=\\\r1", mode=black.FileMode()) == "x = 1\n" + assert black.format_str("x=\\\r1", mode=black.FileMode()) == "x = 1\r" assert ( black.format_str("class A\\\r\n:...", mode=black.FileMode()) - == "class A: ...\n" + == "class A: ...\r\n" ) assert ( black.format_str("class A\\\n:...", mode=black.FileMode()) @@ -2075,9 +2076,17 @@ def test_carriage_return_edge_cases(self) -> None: ) assert ( black.format_str("class A\\\r:...", mode=black.FileMode()) - == "class A: ...\n" + == "class A: ...\r" ) + def test_newline_type_detection(self) -> None: + newline_types = ["A\n", "A\r\n", "A\r"] + for test_case in itertools.permutations(newline_types): + assert ( + black.format_str("".join(test_case), mode=black.FileMode()) + == test_case[0] * 3 + ) + class TestCaching: def test_get_cache_dir( From ec200254ecd108c04706e4af465e043878421eca Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Fri, 18 Jul 2025 01:04:40 -0700 Subject: [PATCH 02/10] Fix tired mistakes --- src/black/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 57ea54976d0..2fbdd0ac891 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -1030,7 +1030,7 @@ def format_stdin_to_stdout( dst += newline f.write(dst) elif write_back in (WriteBack.DIFF, WriteBack.COLOR_DIFF): - now = datetime.now(tz=timezone.utc) + now = datetime.now(timezone.utc) src_name = f"STDIN\t{then}" dst_name = f"STDOUT\t{now}" d = diff(src, dst, src_name, dst_name) @@ -1266,7 +1266,6 @@ def _format_str_once( if "\n" in normalized_contents: return newline_type return "" - # print(f"{src_contents=}\n{normalized_contents=}\n{newline_type=}\n") return "".join(dst_contents).replace("\n", newline_type) @@ -1276,7 +1275,6 @@ def decode_bytes(src: bytes) -> tuple[FileContent, Encoding, NewLine]: `newline` is either CRLF or LF but `decoded_contents` is decoded with universal newlines (i.e. only contains LF). """ - # breakpoint() srcbuf = io.BytesIO(src) encoding, lines = tokenize.detect_encoding(srcbuf.readline) if not lines: From 5f0bdd2ad129ad62079eaf44a6db3681918271ef Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Fri, 18 Jul 2025 01:07:51 -0700 Subject: [PATCH 03/10] Add changelog entry --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index fda755cd3d9..a1c7c3997f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,7 @@ - Remove support for pre-python 3.7 `await/async` as soft keywords/variable names (#4676) - Fix crash on parenthesized expression inside a type parameter bound (#4684) +- Normalize newlines on format to first newline in file (#4710) ### Preview style From a58ea618bac22bc03005484f79ff3799d1e01378 Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Fri, 18 Jul 2025 01:09:59 -0700 Subject: [PATCH 04/10] Update documentation --- docs/the_black_code_style/current_style.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/the_black_code_style/current_style.md b/docs/the_black_code_style/current_style.md index e43a93451d5..72c0de2dadd 100644 --- a/docs/the_black_code_style/current_style.md +++ b/docs/the_black_code_style/current_style.md @@ -417,8 +417,8 @@ file that are not enforced yet but might be in a future version of the formatter ### Line endings -_Black_ will normalize line endings (`\n` or `\r\n`) based on the first line ending of -the file. +_Black_ will normalize line endings (`\n` or `\r\n` or `\r`) based on the first line +ending of the file. ### Form feed characters From 56e3a73de179a2732196c04c042352dfdf08111e Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:40:14 -0700 Subject: [PATCH 05/10] Move changes to preview --- CHANGES.md | 2 +- docs/the_black_code_style/current_style.md | 4 +- docs/the_black_code_style/future_style.md | 2 + src/black/__init__.py | 79 +++++++++++++++------- src/black/mode.py | 1 + src/blackd/__init__.py | 10 +++ tests/test_black.py | 19 +++--- 7 files changed, 79 insertions(+), 38 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a1c7c3997f0..9b8d0346e97 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,7 +22,6 @@ - Remove support for pre-python 3.7 `await/async` as soft keywords/variable names (#4676) - Fix crash on parenthesized expression inside a type parameter bound (#4684) -- Normalize newlines on format to first newline in file (#4710) ### Preview style @@ -33,6 +32,7 @@ - Improve `multiline_string_handling` with ternaries and dictionaries (#4657) - Fix a bug where `string_processing` would not split f-strings directly after expressions (#4680) +- Normalize newlines on format to first newline in file (#4710) ### Configuration diff --git a/docs/the_black_code_style/current_style.md b/docs/the_black_code_style/current_style.md index 72c0de2dadd..e43a93451d5 100644 --- a/docs/the_black_code_style/current_style.md +++ b/docs/the_black_code_style/current_style.md @@ -417,8 +417,8 @@ file that are not enforced yet but might be in a future version of the formatter ### Line endings -_Black_ will normalize line endings (`\n` or `\r\n` or `\r`) based on the first line -ending of the file. +_Black_ will normalize line endings (`\n` or `\r\n`) based on the first line ending of +the file. ### Form feed characters diff --git a/docs/the_black_code_style/future_style.md b/docs/the_black_code_style/future_style.md index b5eb3690f87..ec21c3adcf7 100644 --- a/docs/the_black_code_style/future_style.md +++ b/docs/the_black_code_style/future_style.md @@ -29,6 +29,8 @@ Currently, the following features are included in the preview style: - `fix_fmt_skip_in_one_liners`: Fix `# fmt: skip` behaviour on one-liner declarations, such as `def foo(): return "mock" # fmt: skip`, where previously the declaration would have been incorrectly collapsed. +- `normalize_cr_newlines`: Add `\r` style newlines to the potenial newlines to normalize + file newlines both from and to. (labels/unstable-features)= diff --git a/src/black/__init__.py b/src/black/__init__.py index 2fbdd0ac891..001bdc63192 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -946,7 +946,7 @@ def format_file_in_place( with open(src, "rb") as buf: if mode.skip_source_first_line: header = buf.readline() - src_contents, encoding, newline = decode_bytes(buf.read()) + src_contents, encoding, newline = decode_bytes(buf.read(), mode) try: dst_contents = format_file_contents( src_contents, fast=fast, mode=mode, lines=lines @@ -1008,9 +1008,11 @@ def format_stdin_to_stdout( then = datetime.now(timezone.utc) if content is None: - src, encoding, newline = decode_bytes(sys.stdin.buffer.read()) - else: + src, encoding, newline = decode_bytes(sys.stdin.buffer.read(), mode) + elif Preview.normalize_cr_newlines in mode: src, encoding, newline = content, "utf-8", "\n" + else: + src, encoding, newline = content, "utf-8", "" dst = src try: @@ -1026,8 +1028,12 @@ def format_stdin_to_stdout( ) if write_back == WriteBack.YES: # Make sure there's a newline after the content - if dst and dst[-1] != "\n" and dst[-1] != "\r": - dst += newline + if Preview.normalize_cr_newlines in mode: + if dst and dst[-1] != "\n" and dst[-1] != "\r": + dst += newline + else: + if dst and dst[-1] != "\n": + dst += "\n" f.write(dst) elif write_back in (WriteBack.DIFF, WriteBack.COLOR_DIFF): now = datetime.now(timezone.utc) @@ -1217,11 +1223,17 @@ def f( def _format_str_once( src_contents: str, *, mode: Mode, lines: Collection[tuple[int, int]] = () ) -> str: - normalized_contents, _, newline_type = decode_bytes(src_contents.encode("utf-8")) + if Preview.normalize_cr_newlines in mode: + normalized_contents, _, newline_type = decode_bytes( + src_contents.encode("utf-8"), mode + ) + + src_node = lib2to3_parse( + normalized_contents.lstrip(), target_versions=mode.target_versions + ) + else: + src_node = lib2to3_parse(src_contents.lstrip(), mode.target_versions) - src_node = lib2to3_parse( - normalized_contents.lstrip(), target_versions=mode.target_versions - ) dst_blocks: list[LinesBlock] = [] if mode.target_versions: versions = mode.target_versions @@ -1263,13 +1275,25 @@ def _format_str_once( for block in dst_blocks: dst_contents.extend(block.all_lines()) if not dst_contents: - if "\n" in normalized_contents: - return newline_type + if Preview.normalize_cr_newlines in mode: + if "\n" in normalized_contents: + return newline_type + else: + # Use decode_bytes to retrieve the correct source newline (CRLF or LF), + # and check if normalized_content has more than one line + normalized_content, _, newline = decode_bytes( + src_contents.encode("utf-8"), mode + ) + if "\n" in normalized_content: + return newline return "" - return "".join(dst_contents).replace("\n", newline_type) + if Preview.normalize_cr_newlines in mode: + return "".join(dst_contents).replace("\n", newline_type) + else: + return "".join(dst_contents) -def decode_bytes(src: bytes) -> tuple[FileContent, Encoding, NewLine]: +def decode_bytes(src: bytes, mode: Mode) -> tuple[FileContent, Encoding, NewLine]: """Return a tuple of (decoded_contents, encoding, newline). `newline` is either CRLF or LF but `decoded_contents` is decoded with @@ -1280,21 +1304,24 @@ def decode_bytes(src: bytes) -> tuple[FileContent, Encoding, NewLine]: if not lines: return "", encoding, "\n" - if lines[0][-2:] == b"\r\n": - if b"\r" in lines[0][:-2]: - newline = "\r" - else: - newline = "\r\n" - elif lines[0][-1:] == b"\n": - if b"\r" in lines[0][:-1]: - newline = "\r" + if Preview.normalize_cr_newlines in mode: + if lines[0][-2:] == b"\r\n": + if b"\r" in lines[0][:-2]: + newline = "\r" + else: + newline = "\r\n" + elif lines[0][-1:] == b"\n": + if b"\r" in lines[0][:-1]: + newline = "\r" + else: + newline = "\n" else: - newline = "\n" + if b"\r" in lines[0]: + newline = "\r" + else: + newline = "\n" else: - if b"\r" in lines[0]: - newline = "\r" - else: - newline = "\n" + newline = "\r\n" if lines[0][-2:] == b"\r\n" else "\n" srcbuf.seek(0) with io.TextIOWrapper(srcbuf, encoding) as tiow: diff --git a/src/black/mode.py b/src/black/mode.py index 362607efc86..ba9f6711d54 100644 --- a/src/black/mode.py +++ b/src/black/mode.py @@ -204,6 +204,7 @@ class Preview(Enum): multiline_string_handling = auto() always_one_newline_after_import = auto() fix_fmt_skip_in_one_liners = auto() + normalize_cr_newlines = auto() UNSTABLE_FEATURES: set[Preview] = { diff --git a/src/blackd/__init__.py b/src/blackd/__init__.py index 432ca81a5ae..2f9a516d6e5 100644 --- a/src/blackd/__init__.py +++ b/src/blackd/__init__.py @@ -22,6 +22,7 @@ import black from _black_version import version as __version__ from black.concurrency import maybe_install_uvloop +from black.mode import Preview # This is used internally by tests to shut down the server prematurely _stop_signal = asyncio.Event() @@ -129,6 +130,15 @@ async def handle(request: web.Request, executor: Executor) -> web.Response: executor, partial(black.format_file_contents, req_str, fast=fast, mode=mode) ) + if Preview.normalize_cr_newlines not in mode: + # Preserve CRLF line endings + nl = req_str.find("\n") + if nl > 0 and req_str[nl - 1] == "\r": + formatted_str = formatted_str.replace("\n", "\r\n") + # If, after swapping line endings, nothing changed, then say so + if formatted_str == req_str: + raise black.NothingChanged + # Put the source first line back req_str = header + req_str formatted_str = header + formatted_str diff --git a/tests/test_black.py b/tests/test_black.py index 6ceb8fa759e..ac7b9bb5d46 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2058,17 +2058,17 @@ def test_carriage_return_edge_cases(self) -> None: "try:\\\r# type: ignore\n pass\nfinally:\n pass\n", mode=black.FileMode(), ) - == "try: # type: ignore\r pass\rfinally:\r pass\r" + == "try: # type: ignore\n pass\nfinally:\n pass\n" ) - assert black.format_str("{\r}", mode=black.FileMode()) == "{}\r" - assert black.format_str("pass #\r#\n", mode=black.FileMode()) == "pass #\r#\r" + assert black.format_str("{\r}", mode=black.FileMode()) == "{}\n" + assert black.format_str("pass #\r#\n", mode=black.FileMode()) == "pass #\n#\n" - assert black.format_str("x=\\\r\n1", mode=black.FileMode()) == "x = 1\r\n" + assert black.format_str("x=\\\r\n1", mode=black.FileMode()) == "x = 1\n" assert black.format_str("x=\\\n1", mode=black.FileMode()) == "x = 1\n" - assert black.format_str("x=\\\r1", mode=black.FileMode()) == "x = 1\r" + assert black.format_str("x=\\\r1", mode=black.FileMode()) == "x = 1\n" assert ( black.format_str("class A\\\r\n:...", mode=black.FileMode()) - == "class A: ...\r\n" + == "class A: ...\n" ) assert ( black.format_str("class A\\\n:...", mode=black.FileMode()) @@ -2076,14 +2076,15 @@ def test_carriage_return_edge_cases(self) -> None: ) assert ( black.format_str("class A\\\r:...", mode=black.FileMode()) - == "class A: ...\r" + == "class A: ...\n" ) - def test_newline_type_detection(self) -> None: + def test_preview_newline_type_detection(self) -> None: + mode = Mode(enabled_features={Preview.normalize_cr_newlines}) newline_types = ["A\n", "A\r\n", "A\r"] for test_case in itertools.permutations(newline_types): assert ( - black.format_str("".join(test_case), mode=black.FileMode()) + black.format_str("".join(test_case), mode=mode) == test_case[0] * 3 ) From 828600531e6d2b7e276ff0a324d5017e93d4b617 Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:48:16 -0700 Subject: [PATCH 06/10] Fix test formatting --- tests/test_black.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_black.py b/tests/test_black.py index 0ec4c053947..36ee7d9e1b9 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -2088,10 +2088,7 @@ def test_preview_newline_type_detection(self) -> None: mode = Mode(enabled_features={Preview.normalize_cr_newlines}) newline_types = ["A\n", "A\r\n", "A\r"] for test_case in itertools.permutations(newline_types): - assert ( - black.format_str("".join(test_case), mode=mode) - == test_case[0] * 3 - ) + assert black.format_str("".join(test_case), mode=mode) == test_case[0] * 3 class TestCaching: From c0e266b019d9e66d66877552f0d6b0848db62af0 Mon Sep 17 00:00:00 2001 From: MeGaGiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Tue, 16 Sep 2025 12:51:01 -0700 Subject: [PATCH 07/10] Update schema --- src/black/resources/black.schema.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/black/resources/black.schema.json b/src/black/resources/black.schema.json index c3d7d03d4cc..549e0e8049f 100644 --- a/src/black/resources/black.schema.json +++ b/src/black/resources/black.schema.json @@ -87,7 +87,8 @@ "always_one_newline_after_import", "fix_fmt_skip_in_one_liners", "wrap_comprehension_in", - "remove_parens_around_except_types" + "remove_parens_around_except_types", + "normalize_cr_newlines" ] }, "description": "Enable specific features included in the `--unstable` style. Requires `--preview`. No compatibility guarantees are provided on the behavior or existence of any unstable features." From 21d415e643b43cab1f4cb02b433865a264ac70c6 Mon Sep 17 00:00:00 2001 From: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:47:59 -0700 Subject: [PATCH 08/10] Fix typo in CHANGES.md Co-authored-by: Jelle Zijlstra --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a59836287f1..8bbaa13e2db 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,7 +37,7 @@ - Wrap the `in` clause of comprehensions across lines if necessary (#4699) - Remove parentheses around multiple exception types in `except` and `except*` without `as`. (#4720) -- Add `\r` style newlines to the potenial newlines to normalize file newlines both from +- Add `\r` style newlines to the potential newlines to normalize file newlines both from and to (#4710) ### Configuration From c6750987d63c7dfb79980d8a5fe16b9624d41c37 Mon Sep 17 00:00:00 2001 From: GiGaGon <107241144+MeGaGiGaGon@users.noreply.github.com> Date: Tue, 16 Sep 2025 14:48:07 -0700 Subject: [PATCH 09/10] Fix typo in docs/the_black_code_style/future_style.md Co-authored-by: Jelle Zijlstra --- docs/the_black_code_style/future_style.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/the_black_code_style/future_style.md b/docs/the_black_code_style/future_style.md index 9d19d1e841d..ba95f7a6098 100644 --- a/docs/the_black_code_style/future_style.md +++ b/docs/the_black_code_style/future_style.md @@ -33,7 +33,7 @@ Currently, the following features are included in the preview style: across lines if it would otherwise exceed the maximum line length. - `remove_parens_around_except_types`: Remove parentheses around multiple exception types in `except` and `except*` without `as`. See PEP 758 for details. -- `normalize_cr_newlines`: Add `\r` style newlines to the potenial newlines to normalize +- `normalize_cr_newlines`: Add `\r` style newlines to the potential newlines to normalize file newlines both from and to. (labels/unstable-features)= From d10bab7f98a5fd6ef493ac76c62c7d38201f044c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 21:48:51 +0000 Subject: [PATCH 10/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/the_black_code_style/future_style.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/the_black_code_style/future_style.md b/docs/the_black_code_style/future_style.md index ba95f7a6098..837aec457b0 100644 --- a/docs/the_black_code_style/future_style.md +++ b/docs/the_black_code_style/future_style.md @@ -33,8 +33,8 @@ Currently, the following features are included in the preview style: across lines if it would otherwise exceed the maximum line length. - `remove_parens_around_except_types`: Remove parentheses around multiple exception types in `except` and `except*` without `as`. See PEP 758 for details. -- `normalize_cr_newlines`: Add `\r` style newlines to the potential newlines to normalize - file newlines both from and to. +- `normalize_cr_newlines`: Add `\r` style newlines to the potential newlines to + normalize file newlines both from and to. (labels/unstable-features)=