inference
pyvider.hcl.parser.inference
¶
Automatic CTY type inference from Python data structures.
This module provides HCL-specific wrappers around pyvider-cty's canonical type inference implementation, which correctly handles lists, objects, and all CTY types with sophisticated element type analysis and caching.
Functions¶
auto_infer_cty_type
¶
Automatically infer CTY type from raw Python data.
This function takes Python data structures (typically from HCL parsing) and automatically infers appropriate CTY types using pyvider-cty's canonical inference implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_data
|
Any
|
Python data structure to infer types for |
required |
Returns:
| Type | Description |
|---|---|
CtyValue[Any]
|
CTY value with inferred types |
Example
data = {"name": "test", "count": 5} result = auto_infer_cty_type(data) isinstance(result.type, CtyObject) True
Note
This delegates to pyvider.cty.conversion.infer_cty_type_from_raw() which provides sophisticated type inference including: - List element type analysis (e.g., [1,2,3] → list(number)) - Object attribute inference - Type unification for mixed collections - Caching and cycle detection