"........................................................................... \\N{LAO KO LA}"
)
+msg = lambda x: f"this is a very very very long lambda value {x} that doesn't fit on a single line"
+
+dict_with_lambda_values = {
+ "join": lambda j: (
+ f"{j.__class__.__name__}({some_function_call(j.left)}, "
+ f"{some_function_call(j.right)})"
+ ),
+}
+
+# Complex string concatenations with a method call in the middle.
+code = (
+ (" return [\n")
+ + (
+ ", \n".join(
+ " (%r, self.%s, visitor.%s)"
+ % (attrname, attrname, visit_name)
+ for attrname, visit_name in names
+ )
+ )
+ + ("\n ]\n")
+)
+
+
+# Test case of an outer string' parens enclose an inner string's parens.
+call(body=("%s %s" % ((",".join(items)), suffix)))
+
# output
y = "Short string"
print(
- "This is a really long string inside of a print statement with extra arguments"
- " attached at the end of it.",
+ (
+ "This is a really long string inside of a print statement with extra arguments"
+ " attached at the end of it."
+ ),
x,
y,
z,
"A %s %s"
% ("formatted", "string"): (
"This is a really really really long string that has to go inside of a"
- " dictionary. It is %s bad (#%d)."
- )
- % ("soooo", 2),
+ " dictionary. It is %s bad (#%d)." % ("soooo", 2)
+ ),
}
D5 = { # Test for https://github.com/psf/black/issues/3261
)
bad_split_func1(
- "But what should happen when code has already "
- "been formatted but in the wrong way? Like "
- "with a space at the end instead of the "
- "beginning. Or what about when it is split too "
- "soon? In the case of a split that is too "
- "short, black will try to honer the custom "
- "split.",
+ (
+ "But what should happen when code has already "
+ "been formatted but in the wrong way? Like "
+ "with a space at the end instead of the "
+ "beginning. Or what about when it is split too "
+ "soon? In the case of a split that is too "
+ "short, black will try to honer the custom "
+ "split."
+ ),
xxx,
yyy,
zzz,
)
arg_comment_string = print(
- "Long lines with inline comments which are apart of (and not the only member of) an"
- " argument list should have their comments appended to the reformatted string's"
- " enclosing left parentheses.", # This comment gets thrown to the top.
+ ( # This comment gets thrown to the top.
+ "Long lines with inline comments which are apart of (and not the only member"
+ " of) an argument list should have their comments appended to the reformatted"
+ " string's enclosing left parentheses."
+ ),
"Arg #2",
"Arg #3",
"Arg #4",
)
func_with_bad_comma(
- "This is a really long string argument to a function that has a trailing comma"
- " which should NOT be there.",
+ (
+ "This is a really long string argument to a function that has a trailing comma"
+ " which should NOT be there."
+ ),
)
func_with_bad_comma(
- "This is a really long string argument to a function that has a trailing comma"
- " which should NOT be there.", # comment after comma
+ ( # comment after comma
+ "This is a really long string argument to a function that has a trailing comma"
+ " which should NOT be there."
+ ),
)
func_with_bad_comma(
- "This is a really long string argument to a function that has a trailing comma"
- " which should NOT be there.",
+ (
+ "This is a really long string argument to a function that has a trailing comma"
+ " which should NOT be there."
+ ),
)
func_with_bad_comma(
- "This is a really long string argument to a function that has a trailing comma"
- " which should NOT be there.", # comment after comma
+ ( # comment after comma
+ "This is a really long string argument to a function that has a trailing comma"
+ " which should NOT be there."
+ ),
)
func_with_bad_parens_that_wont_fit_in_one_line(
"..........................................................................."
" \\N{LAO KO LA}"
)
+
+msg = (
+ lambda x: (
+ f"this is a very very very long lambda value {x} that doesn't fit on a single"
+ " line"
+ )
+)
+
+dict_with_lambda_values = {
+ "join": lambda j: (
+ f"{j.__class__.__name__}({some_function_call(j.left)}, "
+ f"{some_function_call(j.right)})"
+ ),
+}
+
+# Complex string concatenations with a method call in the middle.
+code = (
+ " return [\n"
+ + ", \n".join(
+ " (%r, self.%s, visitor.%s)" % (attrname, attrname, visit_name)
+ for attrname, visit_name in names
+ )
+ + "\n ]\n"
+)
+
+
+# Test case of an outer string' parens enclose an inner string's parens.
+call(body="%s %s" % (",".join(items), suffix))