From bc6b912fcbaff08dd0044a844273757c00494305 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Langa?= Date: Wed, 11 Apr 2018 15:49:14 -0700 Subject: [PATCH] Fix an embarrassing UnboundLocalError --- black.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/black.py b/black.py index 3e3ae0a..c7cfa2f 100644 --- a/black.py +++ b/black.py @@ -2088,14 +2088,16 @@ def max_delimiter_priority_in_atom(node: LN) -> int: first = node.children[0] last = node.children[-1] - if first.type == token.LPAR and last.type == token.RPAR: - bt = BracketTracker() - for c in node.children[1:-1]: - if isinstance(c, Leaf): - bt.mark(c) - else: - for leaf in c.leaves(): - bt.mark(leaf) + if not (first.type == token.LPAR and last.type == token.RPAR): + return 0 + + bt = BracketTracker() + for c in node.children[1:-1]: + if isinstance(c, Leaf): + bt.mark(c) + else: + for leaf in c.leaves(): + bt.mark(leaf) try: return bt.max_delimiter_priority() -- 2.39.2