Skip to main content

A simple, type-safe, and extensible Python parsing and validation framework

Project description

🔍 v6e

PyPI version License PyPI - Python Version PyPI - Downloads Contributors

A simple, type-safe, and extensible Python parsing and validation framework

Why the name?

v6e comes from the numeronym of "validate".

Usage

import v6e as v

my_parser = v.int().gte(18).lte(21)

# Use it only to check if the value conforms
my_parser.check(18)  # True
my_parser.check(21)  # True
my_parser.check(54)  # False

# Use `.parse()` (or call it) to validate and get the parsed value
my_parser.parse(21)  # Ok -> Returns 21 (int)
my_parser.parse("21")  # Ok -> Returns 21 (int)
my_parser.parse(54)  # Err -> Raises a ParseException
my_parser(54)  # Err -> Raises a ParseException

v6e also supports custom parsers, custom reusable types, unions of parsers, and more. See more in our docs!

Examples

Check out the examples in ./examples! You can run them locally with:

uv run examples/parsers.py

🐍 Type-checking

This library is fully type-checked. This means that all types will be correctly inferred from the arguments you pass in.

In this example your editor will correctly infer the type:

my_parser = v.int().gte(8).lte(4)
t.reveal_type(my_parser)  # Type of "my_parser" is "V6eInt"
t.reveal_type(my_parser.check)  # Type of "my_parser.check" is "(raw: Any) -> bool"
t.reveal_type(my_parser.safe_parse)  # Type of "my_parser" is "(raw: Any) -> V6eResult[int]"
t.reveal_type(my_parser.parse)  # Type of "my_parser" is "(raw: Any) -> int"
t.reveal_type(my_parser.__call__)  # Type of "my_parser" is "(raw: Any) -> int"

Why should I care?

Type checking will help you catch issues way earlier in the development cycle. It will also provide nice autocomplete features in your editor that will make you faster ⚡.


Alpha notice

This project is still in its alpha phase. Expect frequent and breaking changes. You can see more in our planned work doc.

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

v6e-0.1.17.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

v6e-0.1.17-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file v6e-0.1.17.tar.gz.

File metadata

  • Download URL: v6e-0.1.17.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for v6e-0.1.17.tar.gz
Algorithm Hash digest
SHA256 202c588ad64e4d65abe341c104790a49ec5780c24dca630848ed070e030d2133
MD5 a78e939f7db4e4c2dc02cf7c748650d0
BLAKE2b-256 c69faad469432e0b3809f511874883a9d7b437115dbb2a59af47ffc46d53eb38

See more details on using hashes here.

Provenance

The following attestation bundles were made for v6e-0.1.17.tar.gz:

Publisher: release.yml on danimelchor/v6e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file v6e-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: v6e-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for v6e-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 a3cf31842207b915e4e2a51a1b9b2f7a7668c9dd9eaca77b743ab6a36f8977f1
MD5 e44f50ba0067d0422dd5f8f3f959712d
BLAKE2b-256 33564e6c6b7df5b35932c8533712458d60ef899cc29cab9a1e8aa9e53caf86f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for v6e-0.1.17-py3-none-any.whl:

Publisher: release.yml on danimelchor/v6e

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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