Registry / serialization / typepy

typepy

JSON →
library2.0.0pypypi✓ verified 29d ago

typepy is a Python library for variable type checking, validation, and conversion at runtime. As of version 1.3.4, it supports Python 3.9 and newer. It maintains an active release cadence, with several minor updates per year addressing compatibility, new Python versions, and bug fixes.

pip install typepy
INSTALL
IMPORT
SIG · TYPEPY
T
typepy
serializationpythonv2.0.0
Install
2.6s avg
Import
50ms
Disk
34MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v2.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.054s · 34.5MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 2.6s · import 0.046s · 35MB
34MB installed
● package 34MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TypeConversionError
✓ from typepy import TypeConversionError
✗ import typepy
Typecode
✓ from typepy import Typecode
✗ import typepy
StrictLevel
✓ from typepy import StrictLevel
✗ import typepy

This example demonstrates how to use the `typepy.Type` class for generic type handling and conversion, including providing default values for `None`. It also shows the usage of specific type classes like `typepy.String` and `typepy.Integer` for more focused operations and how to handle potential conversion errors.

import typepy # Generic type checking and conversion tc = typepy.Type('100') print(f"Converted '100' to integer: {tc.try_get(typepy.Type.INTEGER)}") tc_none = typepy.Type(None) print(f"Converted None to string with default: {tc_none.try_get(typepy.Type.STRING, default_value='a')}") # Using specific type classes str_value = typepy.String(' hello ').strip() print(f"Stripped string: '{str_value}'") int_value = typepy.Integer('1,234').convert() print(f"Converted '1,234' to integer: {int_value}") try: # Conversion without try_get will raise an error on failure invalid_int = typepy.Integer('abc').convert() print(f"Converted 'abc' to integer: {invalid_int}") except typepy.TypeConversionError as e: print(f"Error converting 'abc' to integer: {e}")
Debug
Known issues
breakingSupport for Python 3.7 and 3.8 was dropped in version 1.3.3. Ensure your environment uses Python 3.9 or newer.
fix
Upgrade your Python interpreter to version 3.9 or a later compatible version.
affects: >=1.3.3
breakingThe `Binary` type class was renamed to `Bytes` in version 1.1.0 to align with Python 3's `bytes` type. Usage of `Binary` will result in an `AttributeError`.
fix
Replace all instances of `typepy.Binary` with `typepy.Bytes`.
affects: >=1.1.0
breakingSupport for Python 3.6 was dropped in version 1.3.1. `typepy` now requires Python 3.7 (or later, as of 1.3.3).
fix
Upgrade your Python interpreter to version 3.7 or a later compatible version (preferably 3.9+ for current versions).
affects: >=1.3.1
gotchaWhen performing type conversions, `convert()` will raise a `typepy.TypeConversionError` on failure, while `try_get()` allows specifying a `default_value` to return instead of raising an error.
fix
Use `Type(...).try_get(Type.TARGET_TYPE, default_value=...)` when you want to gracefully handle conversion failures with a fallback. Use `Type(...).convert()` (or specific type class `.convert()`) when you expect strict conversion or want to catch and handle specific conversion errors.
affects: All
Upgrade
Version history
2.0.0latest on PyPI · released May 9, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
typepy — pip install typepy · libregistry