From c1a962b88519b42e487ecf3c531bfc689ca1dedf Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Thu, 7 Jun 2018 00:44:12 +0200 Subject: [PATCH] Don't put a space after `*` in `g = 1, *"x"` (#309) Fixes #305. --- black.py | 2 +- tests/expression.diff | 3 ++- tests/expression.py | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/black.py b/black.py index d048162..e72db2b 100644 --- a/black.py +++ b/black.py @@ -1835,7 +1835,7 @@ def whitespace(leaf: Leaf, *, complex_subscript: bool) -> str: # noqa C901 elif prevp.type == token.EQUAL and prevp_parent.type == syms.argument: return NO - elif t == token.NAME or t == token.NUMBER: + elif t in {token.NAME, token.NUMBER, token.STRING}: return NO elif p.type == syms.import_from: diff --git a/tests/expression.diff b/tests/expression.diff index 0d2ff68..8b73f32 100644 --- a/tests/expression.diff +++ b/tests/expression.diff @@ -147,7 +147,7 @@ slice[0:1:2] slice[:] slice[:-1] -@@ -133,108 +156,160 @@ +@@ -133,109 +156,161 @@ numpy[-(c + 1) :, d] numpy[:, l[-2]] numpy[:, ::-1] @@ -184,6 +184,7 @@ d = (1,) + a + (2,) e = (1,).count(1) f = 1, *range(10) + g = 1, *"ten" -what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(vars_to_remove) -what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove) -result = session.query(models.Customer.id).filter(models.Customer.account_id == account_id, models.Customer.email == email_address).order_by(models.Customer.id.asc(),).all() diff --git a/tests/expression.py b/tests/expression.py index ea927a5..b1fa66b 100644 --- a/tests/expression.py +++ b/tests/expression.py @@ -153,6 +153,7 @@ c = 1 d = (1,) + a + (2,) e = (1,).count(1) f = 1, *range(10) +g = 1, *"ten" what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set(vars_to_remove) what_is_up_with_those_new_coord_names = (coord_names | set(vars_to_create)) - set(vars_to_remove) result = session.query(models.Customer.id).filter(models.Customer.account_id == account_id, models.Customer.email == email_address).order_by(models.Customer.id.asc(),).all() @@ -428,6 +429,7 @@ c = 1 d = (1,) + a + (2,) e = (1,).count(1) f = 1, *range(10) +g = 1, *"ten" what_is_up_with_those_new_coord_names = (coord_names + set(vars_to_create)) + set( vars_to_remove ) -- 2.39.5