Skip to main content

prod_assert

The What?

prod_assert is a Python library containing prod safe assert function. This library contains asserts functions as prod_assert (the base assert), assert_eq, assert_in, etc. Asserts in this library, by default, raise AssertionFailed excetption, with the option to raise AssertionError.

The Why?

A senior at work annoyed me by saying I can't use assert in prod, so here are asserts I can use in prod.

Example

from prod_assert import assert_eq

# Nothing happens
assert_eq(1, 1)

# Assert fails and raises AssertionFailde with the default message
assert_eq(1, 2)
### prod_assert._main.AssertionFailed: Condition 1 == 2 is false

# Assert fails and raises AssertionFailed with the custom message
assert_eq(1, 2, "One does not equal two")
### prod_assert._main.AssertionFailed: One does not equal two

# Assert fails and raises AssertionError with the default message
assert_eq(1, 2, assertion_exception=AssertionError)
### AssertionError: Condition 1 == 2 is false

Functions and Classes

class AssertionFailed(Exception):
    pass


AssertionException = Union[AssertionFailed, AssertionError]


def prod_assert(
    condition: bool,
    message: str,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_eq(
    a: Any,
    b: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:
   

def assert_not_eq(
    a: Any,
    b: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_true(
    a: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:
 

def assert_false(
    a: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_is(
    a: Any,
    b: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_is_not(
    a: Any,
    b: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_is_none(
    a: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_is_not_none(
    a: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_in(
    a: Any,
    b: Container[Any],
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_not_in(
    a: Any,
    b: Container[Any],
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_is_instance(
    a: Any,
    b: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:


def assert_not_is_instance(
    a: Any,
    b: Any,
    message: Optional[str]=None,
    assertion_exception: AssertionException=AssertionFailed
) -> None:

Metadata

Release files for prod-assert 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prod-assert 1.0.0
File Size Uploaded Provenance Actions
prod_assert-1.0.0.tar.gz 6.3 kB Without provenance Details for prod_assert-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for prod-assert 1.0.0
File Interpreter ABI Platform Actions
prod_assert-1.0.0-py3-none-any.whl Python 3 none any Details for prod_assert-1.0.0-py3-none-any.whl

Total release size: 13.9 kB

Release files / prod_assert-1.0.0.tar.gz

Download URL prod_assert-1.0.0.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
df04ca52e84fc70a2e178f1770c91a5c0c4eab1e6dfe30d20b03799e804b5957
BLAKE2b-256 checksum
How to use checksums
451744f804d806449a32eb1ea051be3e605e67fa7ad114f913a7663a64ef0c1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / prod_assert-1.0.0-py3-none-any.whl

Download URL prod_assert-1.0.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57107f19a1fccd1b90e48c4d60fdfe62ca6daeed7d00282f397ea45ee0091c31
BLAKE2b-256 checksum
How to use checksums
5868422bb3b03290a34757c00ccb5486c8d221618f79933cf8df0b80018cf7b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for prod-assert 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page