xocto icon indicating copy to clipboard operation
xocto copied to clipboard

Raise exceptions instead of using assertions

Open MocktaiLEngineer opened this issue 2 years ago • 2 comments
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?

MocktaiLEngineer avatar Jul 11 '23 12:07 MocktaiLEngineer

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.

samueljsb avatar Feb 12 '24 15:02 samueljsb

Hey @samueljsb Just raised a PR with regards to this issue: #137

thejasmeetsingh avatar Feb 28 '24 10:02 thejasmeetsingh