@@ -298,10 +298,13 @@ def fix_constr_type_annotations():
298298
299299
300300# Types to unwrap from RootModel to Union type alias.
301- # ALL Request/Response types are unwrapped so consumers can subclass them
302- # with model_config overrides (extra='forbid', custom validators, etc.).
303- # Value-type RootModels (PricingOption, Destination, etc.) keep the RootModel
304- # wrapper + __getattr__ proxy since nobody subclasses them.
301+ # Only genuine discriminated unions (different field shapes per variant) belong here.
302+ # "Validation-only" oneOf types (same fields, different required combos) are now
303+ # handled at the schema level by flatten_validation_oneof() in generate_types.py,
304+ # which produces a single BaseModel class — no RootModel or unwrapping needed.
305+ # Removed from this set (now single classes): GetCreativeDeliveryRequest,
306+ # GetSignalsRequest, ProvidePerformanceFeedbackRequest, SiSendMessageRequest,
307+ # UpdateMediaBuyRequest.
305308# See: https://github.com/adcontextprotocol/adcp-client-python/issues/155
306309_UNWRAP_TO_UNION : set [str ] = {
307310 "AcquireRightsResponse" ,
@@ -315,27 +318,22 @@ def fix_constr_type_annotations():
315318 "GetAccountFinancialsResponse" ,
316319 "GetBrandIdentityResponse" ,
317320 "GetContentStandardsResponse" ,
318- "GetCreativeDeliveryRequest" ,
319321 "GetCreativeFeaturesResponse" ,
320322 "GetMediaBuyArtifactsResponse" ,
321323 "GetPlanAuditLogsRequest" ,
322324 "GetProductsRequest" ,
323325 "GetRightsResponse" ,
324- "GetSignalsRequest" ,
325326 "ListContentStandardsResponse" ,
326327 "LogEventResponse" ,
327328 "PreviewCreativeRequest" ,
328329 "PreviewCreativeResponse" ,
329- "ProvidePerformanceFeedbackRequest" ,
330330 "ProvidePerformanceFeedbackResponse" ,
331- "SiSendMessageRequest" ,
332331 "SyncAccountsResponse" ,
333332 "SyncAudiencesResponse" ,
334333 "SyncCatalogsResponse" ,
335334 "SyncCreativesResponse" ,
336335 "SyncEventSourcesResponse" ,
337336 "UpdateContentStandardsResponse" ,
338- "UpdateMediaBuyRequest" ,
339337 "UpdateMediaBuyResponse" ,
340338 "UpdateRightsResponse" ,
341339 "ValidateContentDeliveryResponse" ,
@@ -526,6 +524,42 @@ def add_rootmodel_getattr_proxy():
526524 print (" No RootModel union types needed __getattr__ proxy" )
527525
528526
527+ def fix_list_field_shadowing ():
528+ """Fix models where a field named 'list' shadows the builtin list type.
529+
530+ GetPropertyListResponse has a field named 'list' which shadows the builtin
531+ list type in annotations like list[Identifier]. We add a _list = list alias
532+ before the class and replace bare list[] usage in annotations.
533+ """
534+ target = OUTPUT_DIR / "property" / "get_property_list_response.py"
535+ if not target .exists ():
536+ return
537+
538+ content = target .read_text ()
539+ if "_list = list" in content :
540+ return # Already fixed
541+
542+ # Add alias before the class definition
543+ content = content .replace (
544+ "\n \n class GetPropertyListResponse(" ,
545+ "\n \n _list = list # alias to avoid shadowing by field name\n \n \n class GetPropertyListResponse(" ,
546+ )
547+
548+ # Replace bare list[] in annotations (but not the 'list' field itself)
549+ # Only replace list[ when used as a type annotation, not as a field name
550+ import re
551+
552+ # Replace list[identifier...] and dict[str, list[identifier...]] patterns
553+ content = re .sub (
554+ r'(?<![._a-zA-Z])list\[identifier\.' ,
555+ '_list[identifier.' ,
556+ content ,
557+ )
558+
559+ target .write_text (content )
560+ print (" Fixed list field shadowing in get_property_list_response.py" )
561+
562+
529563def main ():
530564 """Apply all post-generation fixes."""
531565 print ("Applying post-generation fixes..." )
@@ -539,6 +573,7 @@ def main():
539573 fix_constr_type_annotations ()
540574 unwrap_rootmodel_unions ()
541575 add_rootmodel_getattr_proxy ()
576+ fix_list_field_shadowing ()
542577
543578 print ("\n ✓ Post-generation fixes complete\n " )
544579
0 commit comments