darglint icon indicating copy to clipboard operation
darglint copied to clipboard

Summary error masks other error

Open kannes opened this issue 7 years ago • 2 comments

I am not sure this is a bug or by design. If a summary line is too long darglint will not complain about later errors, in this case an incomplete "Returns".

def f(x):
    """summary
    is too long
    
    Args:
        x: x
        
    Returns"""

    return ""

$ darglint -v 2 /tmp/r.py /tmp/r.py:f:3: S001: Syntax error: s Expected blank line after short description, but found TokenType.WORD: 'is'.

def f(x):
    """summary
    
    Args:
        x: x
        
    Returns"""

    return ""

$ darglint -v 2 /tmp/r.py /tmp/r.py:f:7: S001: Syntax error: s Unable to parse colon: stream was unexpectedly empty.

kannes avatar Nov 14 '18 16:11 kannes

This is actually somewhat by design. Although I don't believe it's a part of the official description, darglint expects a docstring to either be composed of a single line, or a single line + blank line + whatever else. Most, if not all, of the examples in the guide follow this convention. So, when darglint's parser doesn't see that blank line (and the docstring hasn't ended), it fails, resulting in a single error.

In fact, this is related to support for stylistic errors. This is part of the reason I say that support for stylistic errors is a little lacking -- some are ignored completely, others are enforced as hard errors by the parser.

This will get resolved eventually; I've just been too busy after work to tackle it in the last month or two.

terrencepreilly avatar Nov 15 '18 03:11 terrencepreilly

Ah, makes sense. Thanks!

kannes avatar Nov 18 '18 16:11 kannes