Skip to content

Rewrite asserts as exceptions #1408

Open
Open
@akx

Description

@akx

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Contributions WelcomeWe welcome contributions to fix this issue!EnhancementNew feature or requestLow RiskRisk of bugs in transformers and other librariesMedium Priority(will be worked on after all high priority issues)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions