depend¶
depend provides dependent-style typing for Python: runtime-validated, statically assisted, and built around structured predicates.
The library keeps the runtime honest and uses mypy as a useful but incomplete assistant. It is not a complete theorem prover, and it does not try to turn arbitrary Python into logic.
The documentation is built with MkDocs and published to GitHub Pages from this repository.
Quick start¶
from depend import GreaterThan, checked, refined, validate
PositiveInt = refined(int, lambda x: x > 0, name="PositiveInt")
@checked
def repeat(text: str, n: PositiveInt) -> str:
return text * n
assert validate(3, PositiveInt) == 3
assert repeat("ha", 3) == "hahaha"
What to read next¶
refinements.mdforPredicate,where, and known predicateschecked-functions.mdfor@checked,ensure, and return validationsized-collections.mdfor symbolic lengthsnumpy-shapes.mdfor array shapes and dtypesproofs.mdfor proof objects and proof requirementsregistries.mdfor registry metadatamypy-plugin.mdfor plugin setuplimitations.mdfor the edges of the system