@@ -123,29 +123,54 @@ class PythonConfig:
123123 typeddict_total : bool = False
124124
125125 # Declaration
126- type_map : dict = field (init = False )
126+ type_map : dict = field (init = False , repr = False , default_factory = dict )
127127
128128 def __post_init__ (self ) -> None :
129129 """Initialize type map and validate style."""
130130 # Convert string style to enum if needed
131131 if isinstance (self .style , str ):
132- self . style = PythonStyle (self .style )
132+ object . __setattr__ ( self , " style" , PythonStyle (self .style ) )
133133
134134 # Build type map
135- self .type_map = PYTHON_TYPE_MAP .copy ()
136- self .type_map [FieldType .INTEGER ] = self .int_type
137- self .type_map [FieldType .FLOAT ] = self .float_type
138- self .type_map [FieldType .STRING ] = self .string_type
139- self .type_map [FieldType .BOOLEAN ] = self .bool_type
140- self .type_map [FieldType .TIMESTAMP ] = self .datetime_type
141- self .type_map [FieldType .UNKNOWN ] = self .unknown_type
142- self .type_map [FieldType .CONFLICT ] = self .unknown_type
135+ type_map = PYTHON_TYPE_MAP .copy ()
136+ type_map [FieldType .INTEGER ] = self .int_type
137+ type_map [FieldType .FLOAT ] = self .float_type
138+ type_map [FieldType .STRING ] = self .string_type
139+ type_map [FieldType .BOOLEAN ] = self .bool_type
140+ type_map [FieldType .TIMESTAMP ] = self .datetime_type
141+ type_map [FieldType .UNKNOWN ] = self .unknown_type
142+ type_map [FieldType .CONFLICT ] = self .unknown_type
143+
144+ object .__setattr__ (self , "type_map" , type_map )
143145
144146 logger .debug (
145147 f"PythonConfig initialized: style={ self .style .value } , "
146148 f"optional={ self .use_optional } "
147149 )
148150
151+ def to_dict (self ) -> dict :
152+ """Convert to dict, excluding computed fields."""
153+ return {
154+ "style" : (
155+ self .style .value if isinstance (self .style , PythonStyle ) else self .style
156+ ),
157+ "int_type" : self .int_type ,
158+ "float_type" : self .float_type ,
159+ "string_type" : self .string_type ,
160+ "bool_type" : self .bool_type ,
161+ "datetime_type" : self .datetime_type ,
162+ "unknown_type" : self .unknown_type ,
163+ "use_optional" : self .use_optional ,
164+ "dataclass_frozen" : self .dataclass_frozen ,
165+ "dataclass_slots" : self .dataclass_slots ,
166+ "dataclass_kw_only" : self .dataclass_kw_only ,
167+ "pydantic_use_field" : self .pydantic_use_field ,
168+ "pydantic_use_alias" : self .pydantic_use_alias ,
169+ "pydantic_config_dict" : self .pydantic_config_dict ,
170+ "pydantic_extra_forbid" : self .pydantic_extra_forbid ,
171+ "typeddict_total" : self .typeddict_total ,
172+ }
173+
149174 def get_python_type (
150175 self ,
151176 field_type : FieldType ,
@@ -244,6 +269,22 @@ def _extract_base_types(self, type_string: str) -> set[str]:
244269# ============================================================================
245270# Preset Configurations
246271# ============================================================================
272+ def get_python_generator_config (** overrides ) -> dict :
273+ """
274+ Get GeneratorConfig dict with Python-friendly defaults.
275+
276+ Python conventions:
277+ - Classes: PascalCase (struct_case="pascal")
278+ - Fields: snake_case (field_case="snake")
279+ """
280+ defaults = {
281+ "package_name" : "models" ,
282+ "struct_case" : "pascal" ,
283+ "field_case" : "snake" , # Python convention
284+ "add_comments" : True ,
285+ }
286+ defaults .update (overrides )
287+ return defaults
247288
248289
249290def get_dataclass_config () -> PythonConfig :
0 commit comments