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.2

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.2
File Size Uploaded
typing_utilities-0.1.2.tar.gz 19.5 kB Details

Built distribution (wheel)

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

Total release size: 35.0 kB

Release files / typing_utilities-0.1.2.tar.gz

Download URL typing_utilities-0.1.2.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ac158f46fa94e7bdaddb3b97e4409cdd115c7684bc3597cbb78210e344581032
BLAKE2b-256 checksum
How to use checksums
667cba13bdf3573fbfdc1cdf6e4c07b66000891784e9eb9b38385ee54f574826
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 5, 2026.

Transparency log

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

Download URL typing_utilities-0.1.2-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb3edf482aa41fd448898f958fc5457865052bcc85e0acd1616f492a4e3153ad
BLAKE2b-256 checksum
How to use checksums
d969be22ddcf4278d6bf9c07f8c6c36aaf6fbdb33764e4a067cc766c5be61aa9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

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