Smart conversion and validation toolkit powered by type annotations
Project description
Limier
Limier is a smart Python conversion and validation toolkit powered by type annotations.
It is especially handy to automatically cast parameters passed to functions. A typical use case is processing route parameters in the context of web routing.
Install
Limier is released to PyPI and can be installed using pip
:
pip install limier
Basic usage
from limier import deduce, chain
# Custom converter: validate that the input value is positive
def positive(value: int) -> int:
if value < 0:
raise ValueError("Expected positive value")
return value
@deduce
def compute(x: int, times: chain(int, positive)) -> float:
return x * times
result = compute("2", times="2.5")
assert result == 5
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
limier-0.0.1.tar.gz
(6.7 kB
view hashes)
Built Distribution
limier-0.0.1-py3-none-any.whl
(8.8 kB
view hashes)