Skip to main content

Test Coverage Stable Version Pre-release Version PyPI - Python Version PyPI Downloads

Typing Utilities

Utilities for working with complex types and generics in Python — with a focus on validation, correctness, and clarity.

🚀 Why this exists

Python’s type system has become significantly more powerful with the introduction of type hints and generics.

However, working with types at runtime still has challenges:

  • Complex generics are difficult to validate
  • Type relationships are not always easy to reason about
  • Runtime behavior and static typing don’t always align
  • Built-in utilities are limited for advanced scenarios

👉 This library provides tools to bridge the gap between static typing and runtime validation.

✨ Features

  • 🧠 Validation of complex types and generics
  • 🔍 Inspection of type relationships
  • ⚖️ More predictable handling of type constraints
  • 🧩 Utilities for working with advanced typing patterns
  • ⚡ Lightweight and focused API

📦 Use cases

This library is useful when working with:

  • Type-heavy systems
  • Framework or library development
  • Validation layers
  • Data processing systems
  • Dynamic architectures relying on type hints

👉 Especially valuable when type correctness matters beyond static analysis.

🏗 Design philosophy

This project is built around a few core principles:

1. Runtime awareness of types

Type hints shouldn’t just exist for linters — they should be usable and enforceable at runtime where needed.

2. Simplicity over completeness

The goal is not to cover every edge case in Python’s typing system, but to provide practical utilities for real-world problems.

3. Complement, not replace

This library works alongside Python’s built-in typing module, extending it rather than abstracting it away.

🔗 What this enables

By introducing stronger type utilities at runtime, you can:

  • Validate data and inputs more reliably
  • Build safer abstraction layers
  • Reduce subtle bugs caused by incorrect type assumptions
  • Align runtime behavior with type annotations

👉 This is particularly useful in systems where correctness is critical.

⚖️ Trade-offs

Focus ✅ Not a goal ❌
Practical type validation Full typing system reimplementation
Lightweight utilities Heavy abstraction layers
Real-world usefulness Covering every typing edge case

👉 The library prioritizes clarity and usefulness over completeness.

🧠 Context

This project fits into a broader effort to improve:

  • Runtime abstractions
  • Developer tooling
  • Type-driven design in Python

It is particularly complementary to:

  • Dependency injection systems
  • Reflection/introspection tools
  • Validation frameworks

🎯 When to use

Use this library if you:

  • Work with complex or nested types
  • Need runtime validation of generics
  • Build systems where type correctness matters
  • Want better guarantees beyond static analysis

🚫 When not to use

This library may not be necessary if:

  • Your type usage is simple
  • Static type checking (e.g. mypy/pyright) is sufficient
  • Runtime validation is not required

Part of a broader focus on:

  • Clean architecture
  • Runtime introspection
  • Structured Python systems

👉 https://github.com/apmadsen

🤝 Contributing

Feedback and contributions are welcome!

Example:

from typing import Generic, TypeVar
from typingutils import issubclass_typing, isinstance_typing

T = TypeVar('T')

class Class1(Generic[T]):
    pass

class_type1 = Class1[str]
class_type2 = Class1[int]

issubclass_typing(class_type1, class_type2) # => False

# next line will fail
issubclass(class_type1, class_type2) # => TypeErrorr: Subscripted generics cannot be used with class and instance checks

class_inst1 = class_type1()
class_inst2 = class_type2()

isinstance_typing(class_inst1, class_type1) # => True
isinstance_typing(class_inst1, class_type2) # => False
isinstance_typing(class_inst2, class_type2) # => True
isinstance_typing(class_inst2, class_type1) # => False

# next line will fail
isinstance(class_inst1, class_type1) # => TypeError: Subscripted generics cannot be used with class and instance checks

Full documentation

Go to documentation

Metadata

Release files for typing-utilities 0.1.3

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

Source distribution (sdist)

Source distribution for typing-utilities 0.1.3
File Size Uploaded Provenance Actions
typing_utilities-0.1.3.tar.gz 19.9 kB With provenance Details for typing_utilities-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for typing-utilities 0.1.3
File Interpreter ABI Platform Actions
typing_utilities-0.1.3-py3-none-any.whl Python 3 none any Details for typing_utilities-0.1.3-py3-none-any.whl

Total release size: 35.4 kB

Release files / typing_utilities-0.1.3.tar.gz

Download URL typing_utilities-0.1.3.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eea561c1e475b7410ad3781607f4ee440f42eb34d1d30bb3513225497ff86bd0
BLAKE2b-256 checksum
How to use checksums
72247a0027cde5b40b3862890462c183680dcb7eb2b6e0465fd77c037a8e4cf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 27, 2026.

Transparency log

Release files / typing_utilities-0.1.3-py3-none-any.whl

Download URL typing_utilities-0.1.3-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a23161c3232f362ec587b4d96d9e1e4cff63cb379b59583f6d807626b11ad0b6
BLAKE2b-256 checksum
How to use checksums
39213e21c7006d848915ad97d0279e214f86b370aeecde80a8a550d260d917de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 27, 2026.

Transparency log

Security for typing-utilities 0.1.3

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for typing_utilities-0.1.3.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 Oct 27, 2026.

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.

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