Skip to main content

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


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)

Uploaded Source

Built Distribution

limier-0.0.1-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page