A simple flake8 Plugin that checks if assert is used
Project description
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 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8-assert-finder-1.0.tar.gz
.
File metadata
- Download URL: flake8-assert-finder-1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c135794b770a0fcf0d6a90d733cd8c6695d1f9a9e2553d71f40cda5935b2cc0a |
|
MD5 | f64ee93cf4ee47497c7edddea0dba5f8 |
|
BLAKE2b-256 | c1982e16ff90f4904b35ef1c3937610ff1059a94f07a19cc252e1b7194240c59 |
File details
Details for the file flake8_assert_finder-1.0-py3-none-any.whl
.
File metadata
- Download URL: flake8_assert_finder-1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e454410b10ed587187656f42bde43118b9ce318ff22c9623736be1bc8520350d |
|
MD5 | c131ff0c70314cb683251a8934121019 |
|
BLAKE2b-256 | cf977420ad427911029cb1b5dc5c6da162ebb7b7e864f4018f650bbc6aa98b1f |