That’s terrible, and I would block that PR in a heartbeat, unless there was a very good reason for it (given context). I would instead prefer:
if foo isNone:
...
Exceptions are useful for bubbling up errors, they’re a massive code smell if you’re catching something thrown by local logic. Just like you shouldn’t catch IndexError right after indexing a list, you shouldn’t catch TypeError right after checking the length. If you need to check parameters, check them at the start of your function and return early.
That’s terrible, and I would block that PR in a heartbeat, unless there was a very good reason for it (given context). I would instead prefer:
if foo is None: ...
Exceptions are useful for bubbling up errors, they’re a massive code smell if you’re catching something thrown by local logic. Just like you shouldn’t catch
IndexError
right after indexing a list, you shouldn’t catchTypeError
right after checking the length. If you need to check parameters, check them at the start of your function and return early.Sir, I will make sure to never bother you with a PR and my terrible, terrible code ;)