Skip to content

Fix bare except clauses in abstract_solver.py, constraints.py, and monitors.py - #323

Open
koteshyelamati wants to merge 3 commits into
uqfoundation:masterfrom
koteshyelamati:master
Open

Fix bare except clauses in abstract_solver.py, constraints.py, and monitors.py#323
koteshyelamati wants to merge 3 commits into
uqfoundation:masterfrom
koteshyelamati:master

Conversation

@koteshyelamati

Copy link
Copy Markdown

Fix bare except: clauses that catch BaseException, replacing them with specific exception types.

mystic/abstract_solver.py (line 560):
except:except (TypeError, ValueError): — wraps float(var) which can raise TypeError (non-numeric) or ValueError (bad literal).

mystic/constraints.py (line 349):
except:except AttributeError: — wraps guess.copy() which raises AttributeError when the object has no .copy() method.

mystic/monitors.py (line 643):
except:except Exception: — wraps exec(code, _globals) which can raise various exceptions at runtime.

Bare except: clauses are bad practice (PEP 8 / flake8 E722) because they silently swallow KeyboardInterrupt and SystemExit, making programs uninterruptible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant