From: Ɓukasz Langa Date: Thu, 17 May 2018 18:52:47 +0000 (-0700) Subject: Don't allow indexing to trigger omitting optional parentheses X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/385e3a10493c88dc2b71dc11d9d9799d7fcb3b27?ds=sidebyside Don't allow indexing to trigger omitting optional parentheses --- 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: diff --git a/tests/composition.py b/tests/composition.py index 4e7f606..c83db1d 100644 --- a/tests/composition.py +++ b/tests/composition.py @@ -32,11 +32,6 @@ class C: # Another ): print(i) - if _cfg_target_split > [int(x) for x in cur_target.split(".")]: - my_msg = "$MACOSX_DEPLOYMENT_TARGET mismatch: " 'now "%s" but "%s" during configure' % ( - cur_target, - _cfg_target, - ) def omitting_trailers(self) -> None: get_collection( @@ -48,6 +43,9 @@ class C: d[0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20][21][ 22 ] + assignment = ( + some.rather.elaborate.rule() and another.rule.ending_with.index[123] + ) def easy_asserts(self) -> None: assert {