Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion scripts/consolidate_exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,21 +956,59 @@ def generate_domain_exports(
]
lines.extend(
[
"",
"This root is lazy (PEP 562): importing it, or a schema module under it,",
"does not import every schema in the domain. A name is bound from its",
"declaring module on first access and cached here. That is what keeps a",
"schema module's ``from ...<domain> import <sibling>`` from re-entering a",
"half-initialized module through this package (#1784).",
"",
"Auto-generated from the generated domain tree. DO NOT EDIT MANUALLY.",
f"Generation date: {generation_date}",
'"""',
"# ruff: noqa: E501, I001",
"from __future__ import annotations",
"",
"from typing import TYPE_CHECKING",
"",
"if TYPE_CHECKING:",
]
)
for module_name in sorted(by_module):
lines.append(
f"from adcp.types.domains.{module_name} import "
f" from adcp.types.domains.{module_name} import "
f"{', '.join(sorted(by_module[module_name]))}"
)
lines.extend(_format_all_block(sorted(rows)))
lines.extend(
[
"",
"#: The schema module that declares each name, for the lazy binding below.",
"_DECLARED_IN = {",
]
)
for type_name, module_name in sorted(rows.items()):
lines.append(f' "{type_name}": "adcp.types.domains.{module_name}",')
lines.extend(
[
"}",
"",
"if not TYPE_CHECKING:",
" import importlib as _importlib",
"",
" def __getattr__(name: str) -> object:",
" module_name = _DECLARED_IN.get(name)",
" if module_name is None:",
" # Not a declared name: let the import system try a submodule, or fail.",
' raise AttributeError(f"module {__name__!r} has no attribute {name!r}")',
" value = getattr(_importlib.import_module(module_name), name)",
" globals()[name] = value",
" return value",
"",
" def __dir__() -> list[str]:",
" return sorted(set(globals()) | set(__all__))",
]
)
modules[domain] = "\n".join(lines)

root = [
Expand Down
132 changes: 96 additions & 36 deletions src/adcp/types/domains/a2ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,57 @@
it from its own schema's module, ``adcp.types.domains.a2ui.<schema>``.
Nothing here is renamed.

This root is lazy (PEP 562): importing it, or a schema module under it,
does not import every schema in the domain. A name is bound from its
declaring module on first access and cached here. That is what keeps a
schema module's ``from ...<domain> import <sibling>`` from re-entering a
half-initialized module through this package (#1784).

Auto-generated from the generated domain tree. DO NOT EDIT MANUALLY.
Generation date: 2026-10-04 18:45:11 UTC
Generation date: 2026-11-01 23:49:37 UTC
"""

# ruff: noqa: E501, I001
from __future__ import annotations

from adcp.types.domains.a2ui.bound_value import (
A2UiBoundValue,
A2UiBoundValue1,
A2UiBoundValue2,
A2UiBoundValue3,
A2UiBoundValue4,
A2UiBoundValue5,
)
from adcp.types.domains.a2ui.component import A2UiComponent
from adcp.types.domains.a2ui.si_catalog import (
Action23,
Align,
AppHandoff,
Apps,
Button,
Card,
Column,
Component,
Image,
IntegrationAction,
Justify,
Layout,
Link,
List,
ProductCard,
Row,
SiComponentCatalog,
Template,
Text,
Type,
Variant,
Variant4,
)
from adcp.types.domains.a2ui.surface import A2UiSurface
from adcp.types.domains.a2ui.user_action import A2UiUserAction
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from adcp.types.domains.a2ui.bound_value import (
A2UiBoundValue,
A2UiBoundValue1,
A2UiBoundValue2,
A2UiBoundValue3,
A2UiBoundValue4,
A2UiBoundValue5,
)
from adcp.types.domains.a2ui.component import A2UiComponent
from adcp.types.domains.a2ui.si_catalog import (
Action23,
Align,
AppHandoff,
Apps,
Button,
Card,
Column,
Component,
Image,
IntegrationAction,
Justify,
Layout,
Link,
List,
ProductCard,
Row,
SiComponentCatalog,
Template,
Text,
Type,
Variant,
Variant4,
)
from adcp.types.domains.a2ui.surface import A2UiSurface
from adcp.types.domains.a2ui.user_action import A2UiUserAction

# Explicit exports
__all__ = [
Expand Down Expand Up @@ -86,3 +95,54 @@
"Variant",
"Variant4",
]


#: The schema module that declares each name, for the lazy binding below.
_DECLARED_IN = {
"A2UiBoundValue": "adcp.types.domains.a2ui.bound_value",
"A2UiBoundValue1": "adcp.types.domains.a2ui.bound_value",
"A2UiBoundValue2": "adcp.types.domains.a2ui.bound_value",
"A2UiBoundValue3": "adcp.types.domains.a2ui.bound_value",
"A2UiBoundValue4": "adcp.types.domains.a2ui.bound_value",
"A2UiBoundValue5": "adcp.types.domains.a2ui.bound_value",
"A2UiComponent": "adcp.types.domains.a2ui.component",
"A2UiSurface": "adcp.types.domains.a2ui.surface",
"A2UiUserAction": "adcp.types.domains.a2ui.user_action",
"Action23": "adcp.types.domains.a2ui.si_catalog",
"Align": "adcp.types.domains.a2ui.si_catalog",
"AppHandoff": "adcp.types.domains.a2ui.si_catalog",
"Apps": "adcp.types.domains.a2ui.si_catalog",
"Button": "adcp.types.domains.a2ui.si_catalog",
"Card": "adcp.types.domains.a2ui.si_catalog",
"Column": "adcp.types.domains.a2ui.si_catalog",
"Component": "adcp.types.domains.a2ui.si_catalog",
"Image": "adcp.types.domains.a2ui.si_catalog",
"IntegrationAction": "adcp.types.domains.a2ui.si_catalog",
"Justify": "adcp.types.domains.a2ui.si_catalog",
"Layout": "adcp.types.domains.a2ui.si_catalog",
"Link": "adcp.types.domains.a2ui.si_catalog",
"List": "adcp.types.domains.a2ui.si_catalog",
"ProductCard": "adcp.types.domains.a2ui.si_catalog",
"Row": "adcp.types.domains.a2ui.si_catalog",
"SiComponentCatalog": "adcp.types.domains.a2ui.si_catalog",
"Template": "adcp.types.domains.a2ui.si_catalog",
"Text": "adcp.types.domains.a2ui.si_catalog",
"Type": "adcp.types.domains.a2ui.si_catalog",
"Variant": "adcp.types.domains.a2ui.si_catalog",
"Variant4": "adcp.types.domains.a2ui.si_catalog",
}

if not TYPE_CHECKING:
import importlib as _importlib

def __getattr__(name: str) -> object:
module_name = _DECLARED_IN.get(name)
if module_name is None:
# Not a declared name: let the import system try a submodule, or fail.
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
value = getattr(_importlib.import_module(module_name), name)
globals()[name] = value
return value

def __dir__() -> list[str]:
return sorted(set(globals()) | set(__all__))
47 changes: 40 additions & 7 deletions src/adcp/types/domains/aao/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,28 @@
it from its own schema's module, ``adcp.types.domains.aao.<schema>``.
Nothing here is renamed.

This root is lazy (PEP 562): importing it, or a schema module under it,
does not import every schema in the domain. A name is bound from its
declaring module on first access and cached here. That is what keeps a
schema module's ``from ...<domain> import <sibling>`` from re-entering a
half-initialized module through this package (#1784).

Auto-generated from the generated domain tree. DO NOT EDIT MANUALLY.
Generation date: 2026-10-04 18:45:11 UTC
Generation date: 2026-11-01 23:49:37 UTC
"""

# ruff: noqa: E501, I001
from __future__ import annotations

from adcp.types.domains.aao.agent_publishers import (
AaoDirectoryAgentPublishersInverseLookupResponse,
DiscoveryMethod,
PublisherEntry,
Status,
)
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from adcp.types.domains.aao.agent_publishers import (
AaoDirectoryAgentPublishersInverseLookupResponse,
DiscoveryMethod,
PublisherEntry,
Status,
)

# Explicit exports
__all__ = [
Expand All @@ -30,3 +39,27 @@
"PublisherEntry",
"Status",
]


#: The schema module that declares each name, for the lazy binding below.
_DECLARED_IN = {
"AaoDirectoryAgentPublishersInverseLookupResponse": "adcp.types.domains.aao.agent_publishers",
"DiscoveryMethod": "adcp.types.domains.aao.agent_publishers",
"PublisherEntry": "adcp.types.domains.aao.agent_publishers",
"Status": "adcp.types.domains.aao.agent_publishers",
}

if not TYPE_CHECKING:
import importlib as _importlib

def __getattr__(name: str) -> object:
module_name = _DECLARED_IN.get(name)
if module_name is None:
# Not a declared name: let the import system try a submodule, or fail.
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
value = getattr(_importlib.import_module(module_name), name)
globals()[name] = value
return value

def __dir__() -> list[str]:
return sorted(set(globals()) | set(__all__))
Loading
Loading