This is a bad way to do flow control. You should refactor this to avoid catching exceptions. Either declare the variable to something above the `if` block (like `None`), or refactor it so that this code is inside the `if tolerance is not None:` block.