From: Ɓukasz Langa Date: Thu, 12 Apr 2018 06:19:03 +0000 (-0700) Subject: Fix placement of dictionary unpacking inside dict literals X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/19d69b34e5e90589e4be4185852aab7135d59303?ds=sidebyside;hp=--cc Fix placement of dictionary unpacking inside dict literals Fixes #111 --- 19d69b34e5e90589e4be4185852aab7135d59303 diff --git a/README.md b/README.md index d41da0c..c68f703 100644 --- a/README.md +++ b/README.md @@ -495,6 +495,8 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * fixed parsing of unaligned standalone comments (#99, #112) +* fixed placement of dictionary unpacking inside dictionary literals (#111) + ### 18.4a1 * added `--quiet` (#78) diff --git a/black.py b/black.py index c1e83f7..537ba59 100644 --- a/black.py +++ b/black.py @@ -1498,7 +1498,7 @@ def is_split_before_delimiter(leaf: Leaf, previous: Leaf = None) -> int: if ( leaf.type in VARARGS and leaf.parent - and leaf.parent.type in {syms.argument, syms.typedargslist} + and leaf.parent.type in {syms.argument, syms.typedargslist, syms.dictsetmaker} ): # * and ** might also be MATH_OPERATORS but in this case they are not. # Don't treat them as a delimiter. diff --git a/tests/expression.diff b/tests/expression.diff index 965aa00..02bdc2c 100644 --- a/tests/expression.diff +++ b/tests/expression.diff @@ -103,7 +103,7 @@ ] slice[0] slice[0:1] -@@ -114,78 +123,104 @@ +@@ -114,79 +123,113 @@ numpy[-(c + 1):, d] numpy[:, l[-2]] numpy[:, ::-1] @@ -123,6 +123,16 @@ +((i ** 2) for i, _ in ((1, "a"), (2, "b"), (3, "c"))) (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)) (*starred) +-{"id": "1","type": "type","started_at": now(),"ended_at": now() + timedelta(days=10),"priority": 1,"import_session_id": 1,**kwargs} # no trailing comma, this file is not 3.6+ ++{ ++ "id": "1", ++ "type": "type", ++ "started_at": now(), ++ "ended_at": now() + timedelta(days=10), ++ "priority": 1, ++ "import_session_id": 1, ++ **kwargs ++} # no trailing comma, this file is not 3.6+ a = (1,) b = 1, c = 1 diff --git a/tests/expression.py b/tests/expression.py index b03abfa..357cbb6 100644 --- a/tests/expression.py +++ b/tests/expression.py @@ -127,6 +127,7 @@ SomeName ((i ** 2) for i, _ in ((1, 'a'), (2, 'b'), (3, 'c'))) (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)) (*starred) +{"id": "1","type": "type","started_at": now(),"ended_at": now() + timedelta(days=10),"priority": 1,"import_session_id": 1,**kwargs} # no trailing comma, this file is not 3.6+ a = (1,) b = 1, c = 1 @@ -331,6 +332,15 @@ SomeName ((i ** 2) for i, _ in ((1, "a"), (2, "b"), (3, "c"))) (((i ** 2) + j) for i in (1, 2, 3) for j in (1, 2, 3)) (*starred) +{ + "id": "1", + "type": "type", + "started_at": now(), + "ended_at": now() + timedelta(days=10), + "priority": 1, + "import_session_id": 1, + **kwargs +} # no trailing comma, this file is not 3.6+ a = (1,) b = 1, c = 1