Skip to content

Change assertions to exception-raising conditionals #115

@atteggiani

Description

@atteggiani

Overview

As reported by @penguian in this comment, there are assertions in the production code, which is not recommended.

Solution

Replacing assertions with conditionals that raise an error.
Something like:

- assert condition
+ if not condition:
+     raise Exception("...") # Choose the most appropriate Python Exception

For example:

- assert myvar > MINIMUM
+ if myvar <= MINIMUM:
+     raise ValueError(f"'myvar' must be greater than {MINIMUM}. It is {myvar}.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions