Loading CHANGES.md +1 −0 Changes for CHANGES.md: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ ### _Black_ - Account for += assignment when deciding whether to split string (#2312) - Correct max string length calculation when there are string operators (#2292) - Fixed option usage when using the `--code` flag (#2259) - Do not call `uvloop.install()` when _Black_ is used as a library (#2303) Loading src/black/trans.py +1 −1 Changes for src/black/trans.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -867,7 +867,7 @@ def _get_max_string_length(self, line: Line, string_idx: int) -> int: # WMA4 a space, a comma, and a closing bracket [e.g. `), STRING`]. offset += 3 if P.type in [token.COLON, token.EQUAL, token.NAME]: if P.type in [token.COLON, token.EQUAL, token.PLUSEQUAL, token.NAME]: # This conditional branch is meant to handle dictionary keys, # variable assignments, 'return STRING' statement lines, and # 'else STRING' ternary expression lines. Loading tests/data/long_strings__edge_case.py +11 −0 Changes for tests/data/long_strings__edge_case.py: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ assert str(result) == "This long string should be split at some point right close to or around hereeeeeee" assert str(result) < "This long string should be split at some point right close to or around hereeeeee" assert "A format string: %s" % "This long string should be split at some point right close to or around hereeeeeee" != result msg += "This long string should be wrapped in parens at some point right around hereeeee" msg += "This long string should be split at some point right close to or around hereeeeeeee" msg += "This long string should not be split at any point ever since it is just righttt" # output Loading Loading @@ -127,3 +130,11 @@ " hereeeeeee" != result ) msg += ( "This long string should be wrapped in parens at some point right around hereeeee" ) msg += ( "This long string should be split at some point right close to or around" " hereeeeeeee" ) msg += "This long string should not be split at any point ever since it is just righttt" tests/data/long_strings__regression.py +20 −0 Changes for tests/data/long_strings__regression.py: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -407,6 +407,16 @@ def _legacy_listen_examples(): ) class X: async def foo(self): msg = "" for candidate in CANDIDATES: msg += ( "**{candidate.object_type} {candidate.rev}**" " - {candidate.description}\n" ) temp_msg = ( f"{f'{humanize_number(pos)}.': <{pound_len+2}} " f"{balance: <{bal_len + 5}} " Loading Loading @@ -948,6 +958,16 @@ def _legacy_listen_examples(): ) class X: async def foo(self): msg = "" for candidate in CANDIDATES: msg += ( "**{candidate.object_type} {candidate.rev}**" " - {candidate.description}\n" ) temp_msg = ( f"{f'{humanize_number(pos)}.': <{pound_len+2}} " f"{balance: <{bal_len + 5}} " Loading Loading
CHANGES.md +1 −0 Changes for CHANGES.md: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ ### _Black_ - Account for += assignment when deciding whether to split string (#2312) - Correct max string length calculation when there are string operators (#2292) - Fixed option usage when using the `--code` flag (#2259) - Do not call `uvloop.install()` when _Black_ is used as a library (#2303) Loading
src/black/trans.py +1 −1 Changes for src/black/trans.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -867,7 +867,7 @@ def _get_max_string_length(self, line: Line, string_idx: int) -> int: # WMA4 a space, a comma, and a closing bracket [e.g. `), STRING`]. offset += 3 if P.type in [token.COLON, token.EQUAL, token.NAME]: if P.type in [token.COLON, token.EQUAL, token.PLUSEQUAL, token.NAME]: # This conditional branch is meant to handle dictionary keys, # variable assignments, 'return STRING' statement lines, and # 'else STRING' ternary expression lines. Loading
tests/data/long_strings__edge_case.py +11 −0 Changes for tests/data/long_strings__edge_case.py: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -32,6 +32,9 @@ assert str(result) == "This long string should be split at some point right close to or around hereeeeeee" assert str(result) < "This long string should be split at some point right close to or around hereeeeee" assert "A format string: %s" % "This long string should be split at some point right close to or around hereeeeeee" != result msg += "This long string should be wrapped in parens at some point right around hereeeee" msg += "This long string should be split at some point right close to or around hereeeeeeee" msg += "This long string should not be split at any point ever since it is just righttt" # output Loading Loading @@ -127,3 +130,11 @@ " hereeeeeee" != result ) msg += ( "This long string should be wrapped in parens at some point right around hereeeee" ) msg += ( "This long string should be split at some point right close to or around" " hereeeeeeee" ) msg += "This long string should not be split at any point ever since it is just righttt"
tests/data/long_strings__regression.py +20 −0 Changes for tests/data/long_strings__regression.py: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -407,6 +407,16 @@ def _legacy_listen_examples(): ) class X: async def foo(self): msg = "" for candidate in CANDIDATES: msg += ( "**{candidate.object_type} {candidate.rev}**" " - {candidate.description}\n" ) temp_msg = ( f"{f'{humanize_number(pos)}.': <{pound_len+2}} " f"{balance: <{bal_len + 5}} " Loading Loading @@ -948,6 +958,16 @@ def _legacy_listen_examples(): ) class X: async def foo(self): msg = "" for candidate in CANDIDATES: msg += ( "**{candidate.object_type} {candidate.rev}**" " - {candidate.description}\n" ) temp_msg = ( f"{f'{humanize_number(pos)}.': <{pound_len+2}} " f"{balance: <{bal_len + 5}} " Loading