Skip to content

Commit 5844d97

Browse files
bokelleyclaude
andcommitted
refactor: remove direct generated_poc imports
Replace all direct imports from adcp.types.generated_poc with imports from adcp.types._generated. This enforces the public API boundary and prevents downstream users from depending on internal implementation details. Changes: - Update consolidate_exports.py to handle Package name collision by exporting both types with qualified names (_PackageFromPackage, _PackageFromCreateMediaBuyResponse) - Migrate client.py to import TaskStatus from _generated - Migrate aliases.py to import all types from _generated - Migrate stable.py to import Package from _generated using qualified name - Regenerate _generated.py with collision-resolved exports This ensures that: 1. generated_poc directory remains internal (not part of public API) 2. All type consolidation happens in _generated.py 3. Only stable.py and aliases.py provide public type exports 4. Users import from adcp or adcp.types.stable, not internal modules 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 9f63373 commit 5844d97

File tree

5 files changed

+50
-31
lines changed

5 files changed

+50
-31
lines changed

scripts/consolidate_exports.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def generate_consolidated_exports() -> str:
5858
all_exports = set()
5959
collisions = []
6060

61+
# Special handling for known collision: Package type
62+
# We need BOTH Package types available, so import them with qualified names
63+
special_imports = []
64+
package_modules_seen = set()
65+
6166
for module_path in modules:
6267
module_name = module_path.stem
6368
exports = extract_exports_from_module(module_path)
@@ -68,9 +73,15 @@ def generate_consolidated_exports() -> str:
6873
# Filter out names that collide with already-exported names
6974
unique_exports = set()
7075
for export_name in exports:
76+
# Special case: Package collision - track all modules that define it
77+
if export_name == "Package" and module_name in ("package", "create_media_buy_response"):
78+
package_modules_seen.add(module_name)
79+
export_to_module[export_name] = module_name # Track that we've seen it
80+
continue # Don't add to unique_exports, we'll handle specially
81+
7182
if export_name in export_to_module:
72-
# Collision detected - skip this duplicate
7383
first_module = export_to_module[export_name]
84+
# Collision detected - skip this duplicate
7485
collisions.append(
7586
f" {export_name}: defined in both {first_module} and {module_name} (using {first_module})"
7687
)
@@ -91,6 +102,16 @@ def generate_consolidated_exports() -> str:
91102

92103
all_exports.update(unique_exports)
93104

105+
# Generate special imports for Package collision
106+
if package_modules_seen:
107+
collisions.append(f" Package: defined in {sorted(package_modules_seen)} (both exported with qualified names)")
108+
for module_name in sorted(package_modules_seen):
109+
qualified_name = f"_PackageFrom{module_name.replace('_', ' ').title().replace(' ', '')}"
110+
special_imports.append(
111+
f"from adcp.types.generated_poc.{module_name} import Package as {qualified_name}"
112+
)
113+
all_exports.add(qualified_name)
114+
94115
if collisions:
95116
print("\n⚠️ Name collisions detected (duplicates skipped):")
96117
for collision in sorted(collisions):
@@ -121,6 +142,11 @@ def generate_consolidated_exports() -> str:
121142

122143
lines.extend(import_lines)
123144

145+
# Add special imports for name collisions
146+
if special_imports:
147+
lines.extend(["", "# Special imports for name collisions (Package type)"])
148+
lines.extend(special_imports)
149+
124150
# Add backward compatibility aliases (only if source exists)
125151
aliases = {}
126152
if "AdvertisingChannels" in all_exports:

src/adcp/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
ProvidePerformanceFeedbackResponse,
3939
SyncCreativesRequest,
4040
SyncCreativesResponse,
41+
TaskStatus as GeneratedTaskStatus,
4142
WebhookPayload,
4243
)
4344
from adcp.types.core import (
@@ -48,7 +49,6 @@
4849
TaskResult,
4950
TaskStatus,
5051
)
51-
from adcp.types.generated_poc.task_status import TaskStatus as GeneratedTaskStatus
5252
from adcp.utils.operation_id import create_operation_id
5353

5454
logger = logging.getLogger(__name__)

src/adcp/types/_generated.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
DO NOT EDIT MANUALLY.
1111
1212
Generated from: https://github.com/adcontextprotocol/adcp/tree/main/schemas
13-
Generation date: 2025-11-18 12:52:17 UTC
13+
Generation date: 2025-11-19 01:13:16 UTC
1414
"""
1515
# ruff: noqa: E501, I001
1616
from __future__ import annotations
@@ -33,7 +33,7 @@
3333
from adcp.types.generated_poc.cpp_option import CppPricingOption, Parameters
3434
from adcp.types.generated_poc.cpv_option import CpvPricingOption, ViewThreshold, ViewThreshold1
3535
from adcp.types.generated_poc.create_media_buy_request import CreateMediaBuyRequest, ReportingFrequency, ReportingWebhook, RequestedMetric
36-
from adcp.types.generated_poc.create_media_buy_response import CreateMediaBuyResponse, CreateMediaBuyResponse1, CreateMediaBuyResponse2, Package
36+
from adcp.types.generated_poc.create_media_buy_response import CreateMediaBuyResponse, CreateMediaBuyResponse1, CreateMediaBuyResponse2
3737
from adcp.types.generated_poc.creative_asset import CreativeAsset, Input
3838
from adcp.types.generated_poc.creative_assignment import CreativeAssignment
3939
from adcp.types.generated_poc.creative_manifest import CreativeManifest
@@ -113,6 +113,10 @@
113113
from adcp.types.generated_poc.webhook_asset import Method, Method1, ResponseType, Security, WebhookAsset
114114
from adcp.types.generated_poc.webhook_payload import WebhookPayload
115115

116+
# Special imports for name collisions (Package type)
117+
from adcp.types.generated_poc.create_media_buy_response import Package as _PackageFromCreateMediaBuyResponse
118+
from adcp.types.generated_poc.package import Package as _PackageFromPackage
119+
116120
# Backward compatibility aliases for renamed types
117121
Channels = AdvertisingChannels
118122

@@ -146,9 +150,9 @@
146150
"ListCreativesResponse", "Logo", "MarkdownAsset", "MarkdownFlavor", "Measurement",
147151
"MeasurementPeriod", "MediaBuy", "MediaBuyDelivery", "MediaBuyStatus", "Metadata", "Method",
148152
"Method1", "MetricType", "ModuleType", "NotificationType", "Offering", "OutputFormat",
149-
"Pacing", "Package", "PackageRequest", "PackageStatus", "Packages", "Packages1", "Packages2",
150-
"Packages3", "Pagination", "Parameters", "Performance", "PerformanceFeedback", "Placement",
151-
"Preview", "Preview1", "Preview2", "PreviewCreativeRequest", "PreviewCreativeRequest1",
153+
"Pacing", "PackageRequest", "PackageStatus", "Packages", "Packages1", "Packages2", "Packages3",
154+
"Pagination", "Parameters", "Performance", "PerformanceFeedback", "Placement", "Preview",
155+
"Preview1", "Preview2", "PreviewCreativeRequest", "PreviewCreativeRequest1",
152156
"PreviewCreativeRequest2", "PreviewCreativeResponse", "PreviewCreativeResponse1",
153157
"PreviewCreativeResponse2", "PreviewRender", "PreviewRender1", "PreviewRender2",
154158
"PreviewRender3", "PriceGuidance", "Pricing", "PricingModel", "PrimaryCountry", "Product",
@@ -171,5 +175,6 @@
171175
"UpdateMediaBuyResponse", "UpdateMediaBuyResponse1", "UpdateMediaBuyResponse2", "UrlAsset",
172176
"UrlType", "ValidationMode", "VastAsset1", "VastAsset2", "VastVersion",
173177
"VcpmAuctionPricingOption", "VcpmFixedRatePricingOption", "VenueBreakdownItem", "VideoAsset",
174-
"ViewThreshold", "ViewThreshold1", "WebhookAsset", "WebhookPayload"
178+
"ViewThreshold", "ViewThreshold1", "WebhookAsset", "WebhookPayload",
179+
"_PackageFromCreateMediaBuyResponse", "_PackageFromPackage"
175180
]

src/adcp/types/aliases.py

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333

3434
# Import all generated types that need semantic aliases
3535
from adcp.types._generated import (
36+
# Package types (from name collision resolution)
37+
_PackageFromCreateMediaBuyResponse as CreatedPackageInternal,
38+
_PackageFromPackage as FullPackageInternal,
3639
# Activation responses
3740
ActivateSignalResponse1,
3841
ActivateSignalResponse2,
@@ -67,6 +70,12 @@
6770
# Performance feedback responses
6871
ProvidePerformanceFeedbackResponse1,
6972
ProvidePerformanceFeedbackResponse2,
73+
# Publisher properties types
74+
PropertyId,
75+
PropertyTag,
76+
PublisherProperties as PublisherPropertiesInternal,
77+
PublisherProperties4 as PublisherPropertiesByIdInternal,
78+
PublisherProperties5 as PublisherPropertiesByTagInternal,
7079
# SubAssets
7180
SubAsset1,
7281
SubAsset2,
@@ -84,27 +93,6 @@
8493
VastAsset2,
8594
)
8695

87-
# Import Package types directly from their modules to avoid collision issues
88-
from adcp.types.generated_poc.create_media_buy_response import (
89-
Package as CreatedPackageInternal,
90-
)
91-
from adcp.types.generated_poc.package import Package as FullPackageInternal
92-
93-
# Import PublisherProperties types and related types from product module
94-
from adcp.types.generated_poc.product import (
95-
PropertyId,
96-
PropertyTag,
97-
)
98-
from adcp.types.generated_poc.product import (
99-
PublisherProperties as PublisherPropertiesInternal,
100-
)
101-
from adcp.types.generated_poc.product import (
102-
PublisherProperties4 as PublisherPropertiesByIdInternal,
103-
)
104-
from adcp.types.generated_poc.product import (
105-
PublisherProperties5 as PublisherPropertiesByTagInternal,
106-
)
107-
10896
# ============================================================================
10997
# RESPONSE TYPE ALIASES - Success/Error Discriminated Unions
11098
# ============================================================================

src/adcp/types/stable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
)
9494

9595
# Import all generated types from internal consolidated module
96-
# Import Package directly from its module to avoid collision with Response Package
97-
from adcp.types.generated_poc.package import Package
96+
# Import Package from _generated (uses qualified name to avoid collision)
97+
from adcp.types._generated import _PackageFromPackage as Package
9898

9999
# Note: BrandManifest is currently split into BrandManifest1/2 due to upstream schema
100100
# using anyOf incorrectly. This will be fixed upstream to create a single BrandManifest type.

0 commit comments

Comments
 (0)