Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

False positive DAR101 and DAR102 with raw docstring and variadic arguments. #167

Closed
MT-0 opened this issue Apr 28, 2021 · 2 comments
Closed

Comments

@MT-0
Copy link

MT-0 commented Apr 28, 2021

With the test.py file:

def test_function(*args: int) -> int:
    r"""Test a docstring with variadic arguments.
    
    Args:
        \*args:
            A list of integers.
    
    Returns:
        int: The first number else 0.
    """
    return args[0] if args else 0

and the .darglint file:

[darglint]
docstring_style = google
strictness = full

Running darglint test.py outputs:

test.py:test_function:4: DAR101: - *args
test.py:test_function:5: DAR102: + \*args
@terrencepreilly
Copy link
Owner

It's because of the backslash. A backslash isn't necessary, because there's no pattern matching or anything; an '' is just an ''. You should be able to change "*args" to "*args" or "args" and it ought to work.

@MT-0
Copy link
Author

MT-0 commented Apr 28, 2021

This arose from a conflict between the errors raise by darglint and flake8-rst-docstrings. The above code validates using flake8-rst-docstrings but does not in darglint and removing the backslash then the reverse is true.

Looking at https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html#example-google then it seems that the backslash is expected outside the "Args" section (so that * is not interpreted as the start of an emphasis block) but there is a special case in the "Args" section where it is not expected.

It looks like there is an open issue in flake8-rst-docstrings about this and it needs fixing at their end rather than in this package.

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

No branches or pull requests

2 participants