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

Sphinx prefers escaping the asterisk for *args and **kwargs with a backslash but this confuses pydoclint #92

Closed
tmke8 opened this issue Oct 19, 2023 · 5 comments · Fixed by #94

Comments

@tmke8
Copy link

tmke8 commented Oct 19, 2023

Given this

def f(*args, **kwargs):
    """My function.

    :param *args: Positional args.
    :param **kwargs: Keyword args.
    """

sphinx throws a warning:

WARNING: Inline emphasis start-string without end-string.

and this also seems to mess with the formatting a bit.

But when it's escaped with a backslash, it's fine:

def f(*args, **kwargs):
    """My function.

    :param \\*args: Positional args.
    :param \\**kwargs: Keyword args.
    """

However, pydoclint then complains:

 DOC103: Function `f`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [**kwargs: Any]. Arguments in the docstring but not in the function signature: [\**kwargs: ].

So, it seems the backslash confuses pydoclint.

@jsh9
Copy link
Owner

jsh9 commented Oct 20, 2023

Hi, I could not reproduce this issue. Could you double check your code snippet, and can you provide the configs that you used?

Thanks!

@tmke8
Copy link
Author

tmke8 commented Oct 20, 2023

Oh, sorry about that! I didn't check that my minimal reproduction still had the error... rookie mistake.

It seems there need to be type annotations for this to happen:

from typing import Any


def f(*args: Any, **kwargs: Any) -> None:
    """My function.

    :param \\*args: Positional args.
    :param \\**kwargs: Keyword args.
    """

Save this as args_kwargs.py and run

pydoclint --style=sphinx --arg-type-hints-in-docstring=False --check-return-types=False --check-yield-types=False args_kwargs.py

gives

Loading config from user-specified .toml file: pyproject.toml
File "pyproject.toml" does not exist; nothing to load.
Skipping files that match this pattern: \.git|\.tox
args_kwargs.py
args_kwargs.py
    4: DOC103: Function `f`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [**kwargs: Any, *args: Any]. Arguments in the docstring but not in the function signature: [\**kwargs: , \*args: ].

@jsh9
Copy link
Owner

jsh9 commented Oct 20, 2023

Thanks for updating the example! I was able to reproduce it, and I made a code change to fix this bug.

@jsh9
Copy link
Owner

jsh9 commented Oct 20, 2023

Published as 0.3.8 on PyPI.

@tmke8
Copy link
Author

tmke8 commented Oct 20, 2023

Thank you so much! You made a great tool!

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

Successfully merging a pull request may close this issue.

2 participants