Type info
fieldz_kb.typeinfo
Type introspection utilities for fieldz_kb.
This module provides utilities for introspecting type hints, including support for forward references, unions, optionals, and generic types.
Functions:
| Name | Description |
|---|---|
get_types_from_type_hint |
Extract type information from a type hint. |
is_fieldz_class |
Check if a type is a fieldz-supported class (e.g., dataclass). |
is_missing_type |
Check if a type is the fieldz missing type sentinel. |
get_types_from_type_hint
Extract type information from a type hint.
This function recursively processes type hints to extract the underlying
types, handling: - Union types (including Optional) - Generic types (List, Dict, Set, etc.) - Forward references (including string annotations) - Base types
Args:
type_hint: The type hint to process
module: Optional module name for resolving forward references
Returns:
A tuple of (type_origin, type_args) pairs describing the type structure
Raises:
ValueError: If the type hint format is not supported
Source code in src/fieldz_kb/typeinfo.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
is_fieldz_class
Check if a type is a fieldz-supported class (e.g., dataclass).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
The type to check |
required |
Returns:
| Type | Description |
|---|---|
|
True if the type is a fieldz class, False otherwise |
Source code in src/fieldz_kb/typeinfo.py
is_missing_type
Check if a type is the fieldz missing type sentinel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type_
|
The type to check |
required |
Returns:
| Type | Description |
|---|---|
|
True if the type is the missing sentinel, False otherwise |