X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/5dfc911e6b18927b4031a4f2951f9da3fe8f5f8e..385e3a10493c88dc2b71dc11d9d9799d7fcb3b27:/black.py diff --git a/black.py b/black.py index a1a3468..e8af3f0 100644 --- a/black.py +++ b/black.py @@ -2064,12 +2064,22 @@ def right_hand_split( ): omit = {id(closing_bracket), *omit} delimiter_count = body.bracket_tracker.delimiter_count_with_priority() + first = body.leaves[0] + last = body.leaves[-1] if ( delimiter_count == 0 or delimiter_count == 1 and ( - body.leaves[0].type in OPENING_BRACKETS - or body.leaves[-1].type in CLOSING_BRACKETS + first.type in OPENING_BRACKETS + or last.type == token.RPAR + or last.type == token.RBRACE + or ( + # don't use indexing for omitting optional parentheses; + # it looks weird + last.type == token.RSQB + and last.parent + and last.parent.type != syms.trailer + ) ) ): try: