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.2.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

lilvali-0.1.2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lilvali-0.1.2.tar.gz
  • Upload date:
  • Size: 12.7 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.2.tar.gz
Algorithm Hash digest
SHA256 167d6567fb323e86580d687718edcbb8e9f6d9d546c6727835ff92364d1e6d10
MD5 b9cbaa744440d8ec3e5297387d3d258d
BLAKE2b-256 97ed1dea4306b83eab08adf7bc11c27be1024257b05babb5d7579ed86e0cdcd2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lilvali-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8f4c9bd5d0c3db3c2732262da8cd44c29b9f8679038b7069e000d67eeabb3c8f
MD5 f8ac490edcb668f30b04fae3054fb819
BLAKE2b-256 dc4b23346858520fc11142d952c341f36386784a328a1edd951be984b5c85e23

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