Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove asserts from production code #104

Open
gravesm opened this issue Aug 14, 2018 · 0 comments
Open

Remove asserts from production code #104

gravesm opened this issue Aug 14, 2018 · 0 comments

Comments

@gravesm
Copy link

gravesm commented Aug 14, 2018

These are okay in tests, but not something that should generally be used in production code. There are a few cases here where it has been done: https://github.com/MITLibraries/solenoid/search?q=assert&unscoped_q=assert

Just using an if statement will usually make the code cleaner. The most compelling reason to not use asserts is to get more useful exceptions. For example, in https://github.com/MITLibraries/solenoid/blob/master/solenoid/elements/views.py#L90 the better solution will be to just remove any asserts or checks and let the app fail with a KeyError if the item doesn't exist at the time you try to access it.

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

No branches or pull requests

1 participant