Lunderberg opened a new pull request, #11327:
URL: https://github.com/apache/tvm/pull/11327
The `no-else-return` check in pylint has some cases where (to me at least)
it leads to less readable code. In the hypothetical example below, I'd prefer
to use if/elif/else to indicate that these are three mutually distinct options,
each of which results in similar control flow. However, the no-else-return
check requires writing these as separate if statements. This reads as though
each check is independent, inviting the reader to view the if statements in
isolation rather than as a joint structure that exhaustively handles all
options.
```python
# Preferred style
def sign(x):
if x > 0:
return '+'
elif x < 0:
return '-'
else:
return ''
# Required by no-else-return check
def sign(x):
if x > 0:
return '+'
if x < 0:
return '-'
return ''
```
This is not to say that the if/elif/else style should be used exclusively,
but that the style requires by `no-else-return` is not always preferred, and
shouldn't be mandated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]