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

Functions with * (Keyword-Only Arguments) notation render * between each arg #68

Closed
StephenBrown2 opened this issue Mar 30, 2020 · 3 comments

Comments

@StephenBrown2
Copy link
Contributor

StephenBrown2 commented Mar 30, 2020

https://www.python.org/dev/peps/pep-3102/ allows for a * to delineate the following arguments as keyword-only, meaning they cannot be called positionally, even if they have no default value.

However, with mkdocstrings/pytkdocs, it seems the star is added between each argument. e.g.:

async def get_exceptions(
    self, *, calendar_id: int, start_date: pendulum.Date, end_date: pendulum.Date
) -> typing.Dict:

renders as

Screenshot 2020-03-30 at 10 00 38

Feel free to move this issue to pytkdocs if it's more suited to be there.

@pawamoy
Copy link
Member

pawamoy commented Mar 30, 2020

No no it's a rendering issue, it's in the right place 🙂

The signature.html template must be fixed!

@pawamoy
Copy link
Member

pawamoy commented Mar 30, 2020

Seems to be a problem of scope with Jinja2.

With items = [0, 1, 2]:

{% set v = True %}
{% set w = True %}
{% for item in items %}
    {% if w %}
        {% set w = False %}
    {% endif %}
    {{ item }}, v={{ v }}, w={{ w }}
    {% if v %}
        {% set v = False %}
    {% endif %}
{% endfor %}

...rendered template is (minus spaces)

    0, v=True, w=False
    1, v=True, w=False
    2, v=True, w=False

I was expecting

    0, v=True, w=False
    1, v=False, w=False
    2, v=False, w=False

@pawamoy
Copy link
Member

pawamoy commented Mar 30, 2020

It can be fixed with a namespace:

{% set ns = namespace(v = True) %}
{% for item in items %}
    {{ item }}, v={{ ns.v }}
    {% if ns.v %}
        {% set ns.v = False %}
    {% endif %}
{% endfor %}
    0, v=True
    1, v=False
    2, v=False

I'll update the template!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants