Refactor: Replace try/except with contextlib.suppress() by ahzamm · Pull Request #8676 · encode/django-rest-framework (original) (raw)
I can't figure out if this has a breaking change in behaviour because of how the if + 2 try...except was merged down to 1 suppression, specifically for ISO 8601 parsing returning None and continuing through before.
Do any folks who've been involved in maintaining REST framework have opinions on this?
Generally I'm -0 on things like refactoring for the sake of refactoring. With that being said, for this specific case I'm a +0/+1 because I'm very opposed to try...except...pass
blocks, and much prefer the style and clarity of contextlib.suppress()
. Of course, it's always a trade off in terms of time spent reviewing because as a maintainer we like to try to reduce risk with each pull request, and often refactoring PRs don't do that.