assert statements in the code #2456
Gabriel2409
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I noticed that the code contains assert statements at certain places. For example, the
load
function ofConfig
If we consider the following code
we get an assertion error because self.is_ssl is set to True and self_certfile is None
We can disable assertions by running python with the
-O
flag (for ex in prod). So if we run again with the-O
flag, assertion is bypassed and we actually go into thecreate_ssl_context
function before getting aTypeError: certfile should be a valid filesystem path
So my questions is: Are there good reasons to use assert statements instead of just raising an error so that behavior is similar with and without optimization?
Maybe it is because the assert statements here don't protect anything and are just there to help developers.
Anyways, I would love to hear your thoughts on that.
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions