datatyping

datatyping is a Python library, that can verify whether data is well-formed.

This makes datatyping useful for stuff that is currently hard in Python such as documenting incoming data or testing outgoing data.

>>> import datatyping
>>> structure = {'status_code': int, 'content': [str]}
>>> data = {'status_code': 400, 'content': ['Gouda', 'Cheddar']}
>>> datatyping.validate(structure, data)

This approach ensures early failure in a specific spot if data is malformed or has changed format unexpectedly which results in a more explicit codebase that is easier to maintain.

For more, check out Jeff Knupp’s “How Python Makes Working With Data More Difficult in the Long Run” which inspired this library.

Installation

$ pip install datatyping