skillfed

undictify

Type-checked function calls at runtime

undictify v0.11.3 89.8K downloads/30d#13,634 on PyPI98
Permissive license DORMANT released

What it is and what it does

Undictify is a runtime type-checking library that automatically validates function arguments and constructor parameters against their type annotations. It solves the problem of untyped or loosely-typed data (from JSON, external APIs, or dynamic sources) flowing into functions that expect specific types—catching type mismatches at runtime rather than letting them propagate as silent bugs or cryptic errors downstream.

The library provides two main decorators: `@type_checked_call()` for functions and `@type_checked_constructor()` for class constructors. It's particularly useful for deserializing JSON into typed dataclasses or NamedTuples, where you can unpack a dictionary directly into a constructor and let undictify validate all fields match their declared types. It supports optional parameters, type conversions, and selective field skipping, making it practical for web handlers and data ingestion pipelines.

Use it for:

  • Safely deserialize JSON responses into typed dataclasses without manual validation boilerplate
  • Validate HTTP request arguments in Flask/FastAPI handlers where query params arrive as strings
  • Catch type mismatches early when integrating with untyped or dynamically-typed libraries
  • Enforce type contracts on constructor calls when unpacking dictionaries from external sources
  • Reduce repetitive isinstance() checks in data validation code by deriving checks from annotations

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Enforces type annotations at runtime by wrapping function calls and constructors with automatic type-checking, raising TypeError when arguments don't match their declared types.

Yes, if you work with untyped data sources (JSON, APIs, user input) and want runtime type safety without manual validation code. The low install friction and permissive license make it a low-risk addition. However, note that maintenance is dormant (last release 2022-08-12); verify compatibility with your Python version and consider whether the package's scope matches your needs before adopting it for new projects.

Install

undictify on PyPI

pip

pip install undictify

uv

uv add undictify

poetry

poetry add undictify

Installing undictify

Before you install

Low install friction; pure Python wheel with no runtime dependencies. Maintenance is dormant—last release was 2022-08-12, over 1463 days ago, though the repository remains active and unarchived.

License in practice

MIT license (permissive); you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

from undictify import type_checked_call

@type_checked_call()
def times_two(value: int) -> int:
    return 2 * value

result = times_two(3)  # works
times_two('3')  # raises TypeError at runtime

Verify before relying

  • Whether the package works correctly with Python versions beyond 3.9 (classifiers list only 3.7, 3.8, 3.9)
  • Current compatibility with modern type annotation syntax (e.g., PEP 604 union syntax, PEP 585 generics)
  • Performance overhead of runtime type-checking on high-frequency function calls

Package facts

License not declared (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance dormant — 1,463 days since the last release
Last repo commit
First released
Downloads 89,815/month — #13,634 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: undictify-0.11.3-py3-none-any.whl

License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

runtime type checkingtype-checked function callsvalidate function argumentsenforce type annotationsJSON deserialization validationdataclass type validationdictionary unpacking with types
type-checkingdata-validationjson-deserialization

More Quality Assurance packages