Skip to main content

A runtime strict type-checking module for Python designed to validate parametrized (nested) types.

Project description

Nested Type Checker (Beta)

A runtime strict type-checking module for Python designed to validate parametrized (nested) types. It supports both Python built-in types and custom types.

Example Usage

To check if an object matches a specified parametrized type, use the function is_object_of_type(obj, parametrized_type):

from lib.nested_type_checker import is_object_of_type

obj = [123, ({"", True},)]

CorrectType = list[int | tuple[dict[str, bool]]]
WrongType = list[bool | tuple[dict[str, bool]]]

a = is_object_of_type(obj, CorrectType)
b = is_object_of_type(obj, WrongType)

print(a)  # outputs True
print(b)  # outputs False

Support

The module supports can validate mappings, tuples, lists, sets, frozensets, callables, unions, optionals, and any other parametrized or unparametrized types, including custom (unparametrized) types.

Installation

To install, use Python's pip package manager:

pip install nested_type_checker

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

nested_type_checker-0.9.5.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

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

nested_type_checker-0.9.5-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file nested_type_checker-0.9.5.tar.gz.

File metadata

  • Download URL: nested_type_checker-0.9.5.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for nested_type_checker-0.9.5.tar.gz
Algorithm Hash digest
SHA256 c4fb4c5ca01617c78e1740c2edc525f5b97796fa89fbc7b6fd5feca33b159a11
MD5 d1c2a49a4b9aba242a230b8b8354552e
BLAKE2b-256 790d5725bd992161f401ac203f9c33aa365fffb85616322f9d0fdd6863e83972

See more details on using hashes here.

File details

Details for the file nested_type_checker-0.9.5-py3-none-any.whl.

File metadata

File hashes

Hashes for nested_type_checker-0.9.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bbeffe53ce22299e64c0e55d7738a269d99e3446d1291754bb18f25b83cfee6a
MD5 69b47645c98a50f252f568c69aea98c7
BLAKE2b-256 08d1378d6709452501a2fe32ee1f8a290fd4020a8cb332f337a9d2ca5caba426

See more details on using hashes here.

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