Skip to content

Commit

Permalink
Cleanup: remove redundant code path
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Feb 3, 2021
1 parent d262d29 commit 23facce
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions src/black/__init__.py
Expand Up @@ -6604,12 +6604,6 @@ def can_omit_invisible_parens(

penultimate = line.leaves[-2]
last = line.leaves[-1]
if line.should_explode:
try:
penultimate, last = last_two_except(line.leaves)
except LookupError:
# Turns out we'd omit everything. We cannot skip the optional parentheses.
return False

if (
last.type == token.RPAR
Expand Down Expand Up @@ -6683,24 +6677,6 @@ def _can_omit_closing_paren(line: Line, *, last: Leaf, line_length: int) -> bool
return False


def last_two_except(leaves: List[Leaf]) -> Tuple[Leaf, Leaf]:
"""Return (penultimate, last) leaves skipping brackets in `omit` and contents."""
stop_after = None
last = None
for leaf in reversed(leaves):
if stop_after:
if leaf is stop_after:
stop_after = None
continue

if last:
return leaf, last

last = leaf
else:
raise LookupError("Last two leaves were also skipped")


def run_transformer(
line: Line,
transform: Transformer,
Expand Down

0 comments on commit 23facce

Please sign in to comment.