Enable two more
This commit is contained in:
parent
cc3780fd9f
commit
bb31678201
@ -161,16 +161,15 @@ def visit_default(self, node: LN) -> Iterator[Line]:
|
|||||||
def visit_test(self, node: Node) -> Iterator[Line]:
|
def visit_test(self, node: Node) -> Iterator[Line]:
|
||||||
"""Visit an `x if y else z` test"""
|
"""Visit an `x if y else z` test"""
|
||||||
|
|
||||||
if Preview.parenthesize_conditional_expressions in self.mode:
|
already_parenthesized = (
|
||||||
already_parenthesized = (
|
node.prev_sibling and node.prev_sibling.type == token.LPAR
|
||||||
node.prev_sibling and node.prev_sibling.type == token.LPAR
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if not already_parenthesized:
|
if not already_parenthesized:
|
||||||
lpar = Leaf(token.LPAR, "")
|
lpar = Leaf(token.LPAR, "")
|
||||||
rpar = Leaf(token.RPAR, "")
|
rpar = Leaf(token.RPAR, "")
|
||||||
node.insert_child(0, lpar)
|
node.insert_child(0, lpar)
|
||||||
node.append_child(rpar)
|
node.append_child(rpar)
|
||||||
|
|
||||||
yield from self.visit_default(node)
|
yield from self.visit_default(node)
|
||||||
|
|
||||||
@ -230,20 +229,19 @@ def visit_paramspec(self, node: Node) -> Iterator[Line]:
|
|||||||
node.children[1].prefix = ""
|
node.children[1].prefix = ""
|
||||||
|
|
||||||
def visit_dictsetmaker(self, node: Node) -> Iterator[Line]:
|
def visit_dictsetmaker(self, node: Node) -> Iterator[Line]:
|
||||||
if Preview.wrap_long_dict_values_in_parens in self.mode:
|
for i, child in enumerate(node.children):
|
||||||
for i, child in enumerate(node.children):
|
if i == 0:
|
||||||
if i == 0:
|
continue
|
||||||
continue
|
if node.children[i - 1].type == token.COLON:
|
||||||
if node.children[i - 1].type == token.COLON:
|
if child.type == syms.atom and child.children[0].type == token.LPAR:
|
||||||
if child.type == syms.atom and child.children[0].type == token.LPAR:
|
if maybe_make_parens_invisible_in_atom(
|
||||||
if maybe_make_parens_invisible_in_atom(
|
child,
|
||||||
child,
|
parent=node,
|
||||||
parent=node,
|
remove_brackets_around_comma=False,
|
||||||
remove_brackets_around_comma=False,
|
):
|
||||||
):
|
|
||||||
wrap_in_parentheses(node, child, visible=False)
|
|
||||||
else:
|
|
||||||
wrap_in_parentheses(node, child, visible=False)
|
wrap_in_parentheses(node, child, visible=False)
|
||||||
|
else:
|
||||||
|
wrap_in_parentheses(node, child, visible=False)
|
||||||
yield from self.visit_default(node)
|
yield from self.visit_default(node)
|
||||||
|
|
||||||
def visit_funcdef(self, node: Node) -> Iterator[Line]:
|
def visit_funcdef(self, node: Node) -> Iterator[Line]:
|
||||||
|
@ -169,11 +169,7 @@ class Preview(Enum):
|
|||||||
"""Individual preview style features."""
|
"""Individual preview style features."""
|
||||||
|
|
||||||
hex_codes_in_unicode_sequences = auto()
|
hex_codes_in_unicode_sequences = auto()
|
||||||
# NOTE: string_processing requires wrap_long_dict_values_in_parens
|
|
||||||
# for https://github.com/psf/black/issues/3117 to be fixed.
|
|
||||||
string_processing = auto()
|
string_processing = auto()
|
||||||
parenthesize_conditional_expressions = auto()
|
|
||||||
wrap_long_dict_values_in_parens = auto()
|
|
||||||
hug_parens_with_braces_and_square_brackets = auto()
|
hug_parens_with_braces_and_square_brackets = auto()
|
||||||
|
|
||||||
|
|
||||||
|
@ -312,8 +312,8 @@ async def f():
|
|||||||
if (1 if super_long_test_name else 2)
|
if (1 if super_long_test_name else 2)
|
||||||
else (str or bytes or None)
|
else (str or bytes or None)
|
||||||
)
|
)
|
||||||
{"2.7": dead, "3.7": (long_live or die_hard)}
|
{"2.7": dead, "3.7": long_live or die_hard}
|
||||||
{"2.7": dead, "3.7": (long_live or die_hard), **{"3.6": verygood}}
|
{"2.7": dead, "3.7": long_live or die_hard, **{"3.6": verygood}}
|
||||||
{**a, **b, **c}
|
{**a, **b, **c}
|
||||||
{"2.7", "3.6", "3.7", "3.8", "3.9", ("4.0" if gilectomy else "3.10")}
|
{"2.7", "3.6", "3.7", "3.8", "3.9", ("4.0" if gilectomy else "3.10")}
|
||||||
({"a": "b"}, (True or False), (+value), "string", b"bytes") or None
|
({"a": "b"}, (True or False), (+value), "string", b"bytes") or None
|
||||||
|
@ -43,8 +43,10 @@
|
|||||||
% (
|
% (
|
||||||
"formatted",
|
"formatted",
|
||||||
"string",
|
"string",
|
||||||
): "This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
): (
|
||||||
% ("soooo", 2),
|
"This is a really really really long string that has to go inside of a dictionary. It is %s bad (#%d)."
|
||||||
|
% ("soooo", 2)
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
func_with_keywords(
|
func_with_keywords(
|
||||||
|
Loading…
Reference in New Issue
Block a user