bitsandbytes icon indicating copy to clipboard operation
bitsandbytes copied to clipboard

Rewrite `assert`s as exceptions

Open akx opened this issue 1 year ago • 0 comments

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

akx avatar Nov 05 '24 08:11 akx