Skip to main content

Tiny validation library for Python

Project description

lilVali

A small Python 3.12 validation experiment for playing with PEP 695.

Supports most basic typing constructs including Generics.

Install

pip install lilvali

Basic Usage

from lilvali import validate, validator, ValidationError


@validate
def add[T: (int, float)](x: int, y: T) -> int | float:
    return x + y


def main():
    print(f"{add(1, 2)=}")
    print(f"{add(1, 2.0)=}")

    try:
        print(f"{add(1.0, 2)=}")
    except ValidationError as e:
        print(f"{e=}")
    else:
        raise RuntimeError("Expected ValidationError")


if __name__ == "__main__":
    main()

Usage

After installing:

# (Does nothing right now.)
lilvali
from lilvali import validate, validator, ValidationError

Tests

Running tests with coverage
.........................
----------------------------------------------------------------------
Ran 25 tests in 0.006s

OK
Name                           Stmts   Miss  Cover   Missing
------------------------------------------------------------
lilvali/__init__.py                2      0   100%
lilvali/binding.py               167      0   100%
lilvali/errors.py                  6      0   100%
lilvali/validate.py               80      0   100%
tests/test_tiny_validate.py      195      0   100%
tests/test_validate_types.py     124      0   100%
------------------------------------------------------------
TOTAL                            574      0   100%

TODO

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

lilvali-0.1.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

lilvali-0.1.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file lilvali-0.1.1.tar.gz.

File metadata

  • Download URL: lilvali-0.1.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for lilvali-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d6d2c914807ac489c0d9f81da5367af049e7d4a253b940b9bc195467059fbc7
MD5 3def95854338e6e2118627ec04c1826f
BLAKE2b-256 906ecfcf300106c3691dec20833d1b720cdf650f98bac6e67f0db183fd5d9d2a

See more details on using hashes here.

File details

Details for the file lilvali-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lilvali-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for lilvali-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4898f5d248d67b374d29066fe2abe2ff63543641d38d4959b542192951fde1c1
MD5 c7d2fe0b13b5a4095d79d851b0724135
BLAKE2b-256 5ae6d5058c4c6f01e1f8a27b0af577de8ed57d544d0cb69496aefac71784ee89

See more details on using hashes here.

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