Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing keyword only args as positional should fail. #406

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/build/defs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ value). This is in contrast to using context-level variables,
which evaluate to ``UNDEFINED`` if you reference a name that
does not exist.

Note there is a quirk that results in a bare ``*`` being silently removed from
a function definition. The function then incorrectly
allows keyword only arguments to be used as positional arguments.

Calling Defs from Other Files
-----------------------------

Expand Down
19 changes: 19 additions & 0 deletions test/test_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,25 @@ def test_def_py3k_args(self):
"""look at all these args: one two three four 5 seven""",
)

def test_def_py3k_args_quirk(self):
"""Document quirk where bare * is silently removed which incorrectly
allows for kwonly args to be passed as positional.

See issue #405 for more information."""
template = Template(
"""
<%def name="kwonly(a, *, b)">
hello kwonly: ${a} ${b} """
"""
</%def>

${kwonly('1', '2')}"""
)
eq_(
template.render().strip(),
"""hello kwonly: 1 2""",
)

def test_inter_def(self):
"""test defs calling each other"""
template = Template(
Expand Down