diff --git a/src/black/const.py b/src/black/const.py index 04048f30c65..ee466679c70 100644 --- a/src/black/const.py +++ b/src/black/const.py @@ -1,6 +1,4 @@ DEFAULT_LINE_LENGTH = 88 -DEFAULT_EXCLUDES = ( - r"/(\.direnv|\.eggs|\.git|\.hg|\.ipynb_checkpoints|\.mypy_cache|\.nox|\.pytest_cache|\.ruff_cache|\.tox|\.svn|\.venv|\.vscode|__pypackages__|_build|buck-out|build|dist|venv)/" # noqa: B950 -) +DEFAULT_EXCLUDES = r"/(\.direnv|\.eggs|\.git|\.hg|\.ipynb_checkpoints|\.mypy_cache|\.nox|\.pytest_cache|\.ruff_cache|\.tox|\.svn|\.venv|\.vscode|__pypackages__|_build|buck-out|build|dist|venv)/" # noqa: B950 DEFAULT_INCLUDES = r"(\.pyi?|\.ipynb)$" STDIN_PLACEHOLDER = "__BLACK_STDIN_FILENAME__" diff --git a/src/black/linegen.py b/src/black/linegen.py index 8ff7a1dc624..411e65cd558 100644 --- a/src/black/linegen.py +++ b/src/black/linegen.py @@ -982,12 +982,18 @@ def _maybe_split_omitting_optional_parens( if line.is_chained_assignment: pass - # elif not can_be_split(rhs.body) and not is_line_short_enough( - # rhs.body, mode=mode - # ): - # raise CannotSplit( - # "Splitting failed, body is still too long and can't be split." - # ) from e + elif ( + not can_be_split(rhs.body) + and not is_line_short_enough(rhs.body, mode=mode) + and not ( + rhs.opening_bracket.parent + and rhs.opening_bracket.parent.parent + and rhs.opening_bracket.parent.parent.type == syms.dictsetmaker + ) + ): + raise CannotSplit( + "Splitting failed, body is still too long and can't be split." + ) from e elif ( rhs.head.contains_multiline_strings()