Skip to content

Replace assert statements used for runtime validation #638

@Luis-Varona

Description

@Luis-Varona

In many files, assert __ is not None statements are repeatedly used outside of unit tests (e.g., in asset_pricing/covariance.py, iv/absorbing.py, system/model.py, etc.). Running Python in optimization mode (with -O or -OO) will fail to check these assert statements. Beyond this, they're simply less descriptive as generic AssertionErrors compared to, say, TypeErrors with a comprehensive error message (which can explain why we need these assert __is not None checks in the first place). I propose we replace all non-test assert statements with TypeErrors/ValueErrors is appropriate across the codebase; I've already begun drafting a PR. Let me know if, for whatever reason, this is an intentional design choice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions