Skip to content
Myr

Merge pull request #802 from abadger/allow-more-splatting

Before adoption: this commit came in with the history the project adopted, so no landing records it.

More closely match python splatting for calls

authored by David Lord · committed by GitHub · parents a1c5bca, d6c016b · Browse files · 2 files+11 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−4 removed

  • tests:+7 added−2 removed
  • other:+4 added−2 removed

2 files+11 added−4 removed

modified:jinja2/parser.py+4 added-2 removed
775 unmodified lines
776 ensure(dyn_kwargs is None)777 next(self.stream)778 dyn_kwargs = self.parse_expression()779 else:780 ensure(dyn_args is None and dyn_kwargs is None)780 if self.stream.current.type == 'name' and \781 self.stream.look().type == 'assign':782 # Parsing a kwarg783 ensure(dyn_kwargs is None)784 key = self.stream.current.value785 self.stream.skip(2)786 value = self.parse_expression()787 kwargs.append(nodes.Keyword(key, value,788 lineno=value.lineno))789 else:789 ensure(not kwargs)790 # Parsing an arg791 ensure(dyn_args is None and dyn_kwargs is None and not kwargs)792 args.append(self.parse_expression())793794 require_comma = True795 self.stream.expect('rparen')
110 unmodified lines
modified:tests/test_lexnparse.py+7 added-2 removed
371 unmodified lines
372 def test_function_calls(self, env):373 tests = [374 (True, '*foo, bar'),375 (True, '*foo, *bar'),376 (True, '*foo, bar=42'),376 (True, '**foo, *bar'),377 (True, '**foo, bar'),378 (True, '**foo, **bar'),379 (True, '**foo, bar=42'),380 (False, 'foo, bar'),381 (False, 'foo, bar=42'),382 (False, 'foo, bar=23, *args'),383 (False, 'foo, *args, bar=23'),384 (False, 'a, b=c, *d, **e'),383 (False, '*foo, **bar')385 (False, '*foo, bar=42'),386 (False, '*foo, **bar'),387 (False, '*foo, bar=42, **baz'),388 (False, 'foo, *args, bar=23, **baz'),389 ]390 for should_fail, sig in tests:391 if should_fail:392 pytest.raises(TemplateSyntaxError,
265 unmodified lines