python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

Check codebase for appropriate use of exceptions

Open apdavison opened this issue 5 years ago • 2 comments

apdavison avatar Aug 31 '20 08:08 apdavison

e.g. appropriate use of assert vs raising a specific exception

apdavison avatar Aug 31 '20 08:08 apdavison

I see assert used in a lot of places in the library that I think is inappropriate. Generally, I wouldn't use assert outside of tests. For one they're removed if installed or run with the -O flag, so things like type check assertions would succeed when they should fail.

More importantly, given Neo is a library that people use to write their own scripts (i.e., it's not a runnable application), the type of exception raised is important to users of the library. Giving them an AssertionError when a TypeError or RuntimeError would be more appropriate and informative isn't very useful.

achilleas-k avatar Aug 31 '20 11:08 achilleas-k