Closed fredrikaverpil closed 4 years ago
@terrencepreilly hi, I was just wondering if you agree with me that the above reported issue - or if this is a misunderstanding on my part.
Yes, confirmed that this is handled incorrectly. I just haven't had time to handle this yet. I'll give it a look this weekend.
This should be resolved in b33b261e43bd31383efe71f7b9295cdf58c9857b, and the fix will be present in v1.5.6, which I'll try to push this weekend.
It should now be available.
Hi @terrencepreilly I am noticing that with v1.5.7, a bare return now requires a "Returns:" statement in the docstring. Was this a side-effect of allowing bare raising?
If a function never returns anything (always returns None) but you want the function to exit early, it's common practice to do a "bare return". Would you say the intent here is to require a "Returns:" statement in the dosctring in such cases?
Ah, I just saw your comment on that this should be fixed in 1.5.8 👍
Hi again @terrencepreilly
What about this scenario? With darglint 1.5.8, I still get "excessive exceptions in Raises section" (DAR402) for both HTTPError and ConnectionError in the example below:
"""Some script."""
import requests
def something():
"""Something."""
pass
def test_something():
"""Test.
Raises:
HTTPError: if call to something fails...
ConnectionError: if call to something fails...
"""
try:
something()
except (requests.HTTPError, requests.ConnectionError) as err:
print(err)
raise
Similarly, as of 1.5.8:
def foo():
"""Try bar() 5 times.
Raises:
Exception: if bar() excepts 5 times.
"""
for _try in range(5):
try:
bar()
except Exception as exc:
last_exc = exc
raise last_exc
DAR401: Missing exception(s) in Raises section: -r last_exc
DAR402: Excess exception(s) in Raises section: +r Exception
With this code, I get
Excess exception(s) in Raises section: +r TypeErrorflake8(DAR402)
with darglint 1.5.5 via flake8:I feel this is wrong, as I am inside of
x()
indeed re-raisingTypeError
.Related: