darglint icon indicating copy to clipboard operation
darglint copied to clipboard

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

Open yyang-nasuni opened this issue 5 years ago • 3 comments

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

yyang-nasuni avatar Sep 15 '20 19:09 yyang-nasuni

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 avatar Sep 20 '20 15:09 terrencepreilly

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

terrencepreilly avatar Sep 20 '20 19:09 terrencepreilly

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

maltevesper avatar Mar 22 '21 21:03 maltevesper