Skip to main content

flake8-assert-finder

A simple flake8 Plugin that checks if assert is used

The assert Keyword is very useful in Python, but has one big problem: Python has a optimized mode. When using this, The assert Keyword will no longer work, so if you use assert in a Library, this can lead to Problems.

You should replace assert with this little function:

def assert_func(expression: bool) -> None:
    """
    The assert keyword is not available when running Python in optimized mode.
    This function is a drop-in replacement.
    See https://docs.python.org/3/using/cmdline.html?highlight=pythonoptimize#cmdoption-O
    """
    if not expression:
        raise AssertionError()

This makes sure, your will be working.

If you just write your own Program, which you don't use with the optimized mode or if you use something like pytest, you can use assert of course.

This Plugin just checks for the use of the assert Keyword. Nothing more.

List of warnings:

ID Description
AF100 Found assert

Release files for flake8-assert-finder 1.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 flake8-assert-finder 1.0
File Size Uploaded
flake8-assert-finder-1.0.tar.gz 3.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-assert-finder 1.0
File Interpreter ABI Platform
flake8_assert_finder-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / flake8-assert-finder-1.0.tar.gz

Download URL flake8-assert-finder-1.0.tar.gz
Size 3.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c135794b770a0fcf0d6a90d733cd8c6695d1f9a9e2553d71f40cda5935b2cc0a
BLAKE2b-256 checksum
How to use checksums
c1982e16ff90f4904b35ef1c3937610ff1059a94f07a19cc252e1b7194240c59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / flake8_assert_finder-1.0-py3-none-any.whl

Download URL flake8_assert_finder-1.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e454410b10ed587187656f42bde43118b9ce318ff22c9623736be1bc8520350d
BLAKE2b-256 checksum
How to use checksums
cf977420ad427911029cb1b5dc5c6da162ebb7b7e864f4018f650bbc6aa98b1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files

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