xocto
xocto copied to clipboard
Raise exceptions instead of using assertions
trafficstars
https://github.com/octoenergy/xocto/blob/e0446deeb17e333a95d1c27cbf268698efbde3f6/xocto/numbers.py#L21
Assertions can't be relied upon for control flow because they can be disabled, as per the following -
$ python --help
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
...
-O : remove assert and __debug__-dependent statements; add .opt-1 before
.pyc extension; also PYTHONOPTIMIZE=x
-OO : do -O changes and also discard docstrings; add .opt-2 before
.pyc extension
...
Would you be open to me changing these assertions to other appropriate exceptions as I encounter them?
Hi! Sorry for leaving you hanging for so long. You're absolutely right about assertions being no good here. We'd love to see this fixed to raise a better exception.
Hey @samueljsb Just raised a PR with regards to this issue: #137