Skip to main content

Labrea Type Validation

Type validation for labrea using pydantic

lifecycle PyPI Downloads pre-commit Coverage docs

Installation

labrea-type-validation is available for install via pip.

pip install labrea-type-validation

Alternatively, you can install the latest development version from GitHub.

pip install git+https://github.com/8451/labrea-type-validation@develop

Usage

When creating an Option with labrea, specify the expected type using either of the following syntaxes:

from labrea import Option

X = Option("X", type=int)
Y = Option[int]("Y")

Either literal types or type hints can be used, such as List[int] or Union[str, List[str]].

To enable type validation, simply import labrea_type_validation and call the enable function:

import labrea_type_validation

X({"X": "1"})  # No error

labrea_type_validation.enable()

X({"X": "1"})
# ...
# TypeError: Expected type <class 'int'> but got <class 'str'> ('1')
#
# The above exception was the direct cause of the following exception:
#
# Traceback (most recent call last):
# ...
# labrea.exceptions.EvaluationError: Originating in Option('X') | Error during evaluation

Type validation can also be used in a with statement as a context manager using enabled.

with labrea_type_validation.enabled():
    X({"X": "1"})
# ...
# TypeError: Expected type <class 'int'> but got <class 'str'> ('1')
#
# The above exception was the direct cause of the following exception:
#
# Traceback (most recent call last):
# ...
# labrea.exceptions.EvaluationError: Originating in Option('X') | Error during evaluation

Alternatively, the LABREA_TYPE_VALIDATION_ENABLED environment variable can be set to TRUE.

Multithreaded Applications

Type validation is based on the labrea.runtime module. For this reason, type validation is enabled for the current thread and any threads spawned from it. If you are using a multithreaded application, ensure that type validation is enabled in the main thread before spawning any new threads.

Contributing

If you would like to contribute to labrea-type-validation, please read the Contributing Guide.

Changelog

A summary of recent updates to labrea-type-validation can be found in the Changelog.

Maintainers

Maintainer Email
Austin Warner austin.warner@8451.com
Michael Stoepel michael.stoepel@8451.com

Metadata

Release files for labrea-type-validation 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for labrea-type-validation 0.0.1
File Size Uploaded Provenance Actions
labrea_type_validation-0.0.1.tar.gz 201.6 kB With provenance Details for labrea_type_validation-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for labrea-type-validation 0.0.1
File Interpreter ABI Platform Actions
labrea_type_validation-0.0.1-py3-none-any.whl Python 3 none any Details for labrea_type_validation-0.0.1-py3-none-any.whl

Total release size: 207.9 kB

Release files / labrea_type_validation-0.0.1.tar.gz

Download URL labrea_type_validation-0.0.1.tar.gz
Size 201.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f9229be64c3ed02e875e23c5ad7ed46a993a1ba7fb61ed527272629ca8f8b62f
BLAKE2b-256 checksum
How to use checksums
6318da0e4916e31ae7217e4d526c5d80950cbcc3927e1ad972677ad14dcc60b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2025.

Transparency log

Release files / labrea_type_validation-0.0.1-py3-none-any.whl

Download URL labrea_type_validation-0.0.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86a861d0a957aef0e2324b05d6a1a325520b47eb9071ce36480a4d4b7f82739a
BLAKE2b-256 checksum
How to use checksums
b8678d1080b5aa972019d647f4000eed862333f60793f02f0d44e775ce0f7998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2025.

Transparency log

Security for labrea-type-validation 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for labrea_type_validation-0.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 8, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page