by BiteCode_dev · 5y ago · 0 comments
We still have -X dev and sys.flags but it's runtime only.
I’ve been guilty of that in my own code when I just want to tell myself about an error.
Would be interesting to scan pypi and check if this is still a thing.
Maybe create a bot warning lib authors.
While today's use case for assert is unit testing, the actual killer feature of the keyword is that it's removed only from prod.
The idea is that you can write things like function contracts, that are expensive, but only exist in dev.
Now, if one of you dependencies use assert for something they expect to still be in prod, which is the problem we are talking about in the first place, "-o" or "--remove-assertions" will strip their assert too, breaking their code, and hence, yours since it depends on it.