From 92c611cfdf1124d0d2830ba9a503a7e7a57d2dee Mon Sep 17 00:00:00 2001 From: williamfzc <178894043@qq.com> Date: Fri, 8 May 2020 21:16:57 +0800 Subject: [PATCH] add bracket check in split_line (#1315) --- black.py | 1 + tests/data/comments.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/black.py b/black.py index 7b905ee..087683a 100644 --- a/black.py +++ b/black.py @@ -2544,6 +2544,7 @@ def transform_line( is_line_short_enough(line, line_length=line_length, line_str=line_str) or line.contains_unsplittable_type_ignore() ) + and not (line.contains_standalone_comments() and line.inside_brackets) ): # Only apply basic string preprocessing, since lines shouldn't be split here. transformers = [string_merge, string_paren_strip] diff --git a/tests/data/comments.py b/tests/data/comments.py index a20e653..c34daaf 100644 --- a/tests/data/comments.py +++ b/tests/data/comments.py @@ -22,6 +22,11 @@ except ImportError: # Some comment before a function. +y = 1 +( + # some strings + y # type: ignore +) def function(default=None): -- 2.39.2