terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
482 stars 41 forks source link

Raised exceptions not detected in "else" or "finally" blocks after darglint 1.2.0 #127

Open yyang-nasuni opened 4 years ago

yyang-nasuni commented 4 years ago

Here is the sample code and darglint==1.2.0 can detect missing raises doc strings for both errors in else and finally blocks. After upgrading to latest darglint==1.5.4, these missing exception doc errors are not reported.

Is this expected in newer version to skip checking raise in such else and finally blocks? Thank you.

# sample.py
def func() -> None:
    """Test."""
    try:
        1 // 0
    except Exception:
        pass
    else:
        raise ValueError('error in except')
    finally:
        raise RuntimeError('error in finally')
# darglint 1.2.0

darglint sample.py 
sample.py:func:1: DAR401: -r RuntimeError
sample.py:func:1: DAR401: -r ValueError
# darglint 1.5.4

darglint sample.py 
# empty - no error reported
terrencepreilly commented 4 years ago

I don't think darglint ever handled them explicitly -- it was kind of an accidental catch. I think this should be pretty easy to handle, though, so we should cover it. Thanks for pointing it out!

terrencepreilly commented 4 years ago

Fixed in 62802244d2d390fec9099b822639761c2efe6b60. Should be present in 1.5.5, when that's released.

maltevesper commented 3 years ago

@terrencepreilly I believe this issue can be closed since you released 1.5.5 in the mean time :).