CCI-MOC / moc-openstack-tools

Tools for OpenStack administration, user/project management, etc.
Apache License 2.0
0 stars 8 forks source link

Remove bare except blocks #103

Open ianballou opened 6 years ago

ianballou commented 6 years ago

There are bare except blocks in addusers.py and reset-password.py. It would be a better practice to write which exceptions we expect to be caught there.

Example: https://github.com/CCI-MOC/moc-openstack-tools/blob/master/addusers.py#L118

ianballou commented 6 years ago

What do we think about using except BaseException: to circumvent the flake8 check? Otherwise we could rewrite the logic so that the except isn't needed.

kamfonik commented 6 years ago

I think all the bare except blocks call "raise" so they shouldn't do too much harm. I put some of these around email sending, because the errors are different depending on what mail program you're using. The purpose was to dump the filled-in email template to file, which is useful when everything works but the email step - at least at the time, it often made sense in that case to just send the email manually.

This doesn't mean you shouldn't make the mechanism better. In the meantime you can ignore this error for individual lines by adding # noqa: E722 to the end of the line.