bitsandbytes-foundation / bitsandbytes

Accessible large language models via k-bit quantization for PyTorch.
https://huggingface.co/docs/bitsandbytes/main/en/index
MIT License
6.31k stars 634 forks source link

Rewrite `assert`s as exceptions #1408

Open akx opened 2 weeks ago

akx commented 2 weeks ago

We're planning to take a library-wide sweep through these separately. For now, I'm following the existing patterns, but it is on the backlog. – original

I've used ast-grep spells like this in the past (YMMV, just found these in my shell history):

ast-grep run --pattern 'assert $A' --rewrite 'if not ($A): raise AssertionError("$A")' -l python -i src
ast-grep run --pattern 'assert $$$A, $B' --rewrite 'if not ($A): raise AssertionError($B)' -l python -i src