Skip to content

Commit fbfb812

Browse files
ianjosephwilsonzzzeek
authored andcommitted
Document / test quirk that kw only args can be passed positionally
Rather than making a backwards incompatible change, document the quirk and add a test for it. Fixes: #405 Closes: #406 Pull-request: #406 Pull-request-sha: 0ad95a2 Change-Id: Id66fb5b59c18e60e35479ad553deb7a314ccfaa5
1 parent 9537b26 commit fbfb812

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

doc/build/defs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ value). This is in contrast to using context-level variables,
7373
which evaluate to ``UNDEFINED`` if you reference a name that
7474
does not exist.
7575

76+
Note there is a quirk that results in a bare ``*`` being silently removed from
77+
a function definition. The function then incorrectly
78+
allows keyword only arguments to be used as positional arguments.
79+
7680
Calling Defs from Other Files
7781
-----------------------------
7882

test/test_def.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ def test_def_py3k_args(self):
6262
"""look at all these args: one two three four 5 seven""",
6363
)
6464

65+
def test_def_py3k_args_quirk(self):
66+
"""Document quirk where bare * is silently removed which incorrectly
67+
allows for kwonly args to be passed as positional.
68+
69+
See issue #405 for more information."""
70+
template = Template(
71+
"""
72+
<%def name="kwonly(a, *, b)">
73+
hello kwonly: ${a} ${b} """
74+
"""
75+
</%def>
76+
77+
${kwonly('1', '2')}"""
78+
)
79+
eq_(
80+
template.render().strip(),
81+
"""hello kwonly: 1 2""",
82+
)
83+
6584
def test_inter_def(self):
6685
"""test defs calling each other"""
6786
template = Template(

0 commit comments

Comments
 (0)