stouputils.typing package#

This module provides utilities for typing enhancements:

  • JsonDict, JsonList - Type aliases for JSON data

  • JsonMap, JsonMutMap - Read-only and mutable mapping aliases for JSON data

  • IterAny, CallableAny - Type aliases for iterables and callables

  • ClassInfo - Type alias for what isinstance accepts

  • is_generic_instance() - Runtime equivalent of isinstance() for generic type hints like dict[str, int]

  • is_sequence() - Check if an object supports O(1) __len__ and __getitem__

  • convert_to_serializable() - Recursively convert objects (dataclasses, defaultdicts, …) to JSON-serializable forms

  • @inheritable - Mark a class as meant to be subclassed

  • @overridable - Mark a member as a default implementation that subclasses may replace

  • @hook - Mark a method as a hook the base class calls at a fixed point of its flow

Submodules#