Skip to main content

A python package for checks and assertions of data and objects

Project description


This package provides for inline checks (i.e. checkers) which assure that objects can meet a complicated set of assumptions. Special handling of raised exceptions allow the collection of multiple exceptions to these assertions before interrupting the process. You can think of this as a close relative to unit testing, where you get the benefits of a robust set of checks which can report errors independent of one another, with the convenience of single method type checking.

If exceptions are found, they are re-raised with a complete list of all the exceptions identified during the check. If no exceptions are found, the checker will return the original value that was passed to it.


from checkplz import sequence
# example 1
x = sequence([1,2,3])
# example 2
y = sequence([1,2,5])

In the first example, the sequence matches the assumptions of the checker. Because no exceptions are identified, the object provider ([1,2,3]) will be assigned to the object x. However, in the second, the sequence has a gap which violates the assumptions of the checker. This will result in an exception being raised before the assignment to y can occur.

The utility of these simple assertions can be better shown when they are used in a more complex scenario. For our next example, let's say we're interested in taking a list of lists, and checking each of them individually for proper sequencing.

from checkplz import sequence
list_of_lists = [
# example 3
lol = [sequence(z) for z in list_of_lists]
# example 4
min_lol = [min(sequence(z)) for z in list_of_lists]

Here we use the checker as part of an inline list comprehension, and you can see the utility of such concise syntax. In example #3, we simply assign the object back to a list comprehension, in effect recreating an identical object, using the checker as an opportunity to raise exceptions for anything that violates our assumptions. In example #4, we wrap the checked result in an additional function, allowing us to first check the object before moving on with an additional step that prevents us from performing the check later.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for checkplz, version 0.0.5
Filename, size File type Python version Upload date Hashes
Filename, size checkplz-0.0.5-py3-none-any.whl (6.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size checkplz-0.0.5.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page