Open daniel-klein opened 10 months ago
I am still in favor of explicit return
s, but we can revisit at a later date. PEP8 and the Google Style Guide don't cover this point, other than to recommend using an explicit return None
if non-None
return values are also possible from a function. RealPython suggests that omitting return
can be confusing for users coming from other languages. I agree that it doesn't make much difference which convention we choose, so long as we are consistent about it!
The style guide recommends that all functions end with an empty
Return
statement. This statement has the effect of returningNone
from the function. However, the same functionality can be achieved without the return statement becauseNone
is returned automatically when the end of a function is reached.Personally, I find it annoying to have (inconsistent)
Return
statements sprinkled throughout the code. I find they confuse more than add to readability.In chatting with @cliffckerr, one consideration of recommending that all functions end with a return is that it forces developers to consider if
None
is really the best return value. TBH, I'm not convinced this specific recommendation in the style guide has the intended consequences.My recommendation is to change the style guide to recommend against concluding every function with a return statement.