The bit I really care about is you shouldn't catch the `TypeError`. You've already checked the type so you don't expect a `TypeError` to be raised, so if one does crop up it's a genuine error and shouldn't be silenced.

After that, I still think the use of the `ValueError` suggests a more elegant refactor is possible ... but I'm not going to get hung up on that.