models_loader

Lazy import of the generated model modules.

atproto_client.models.models_loader.make_lazy_accessors(package_name: str, fallback: str | None = None) β†’ Tuple[Callable[[str], Any], Callable[[], List[str]]]

Build __getattr__/__dir__ for the lazily-loaded models package.

Resolved attributes are cached on the package, so each accessor runs at most once per name.

Parameters:
  • package_name – The models package these accessors belong to.

  • fallback – Models package to defer to for names this one does not define.

atproto_client.models.models_loader.prepare_model_module(module: ModuleType, models_root: ModuleType | None = None) β†’ None

Inject the forward-reference namespace into a freshly imported generated model module.

Pydantic resolves the string forward references against the module’s globals when it (lazily) builds each model’s schema on first validation, so the names must be present there.

Parameters:
  • module – The freshly imported generated model module.

  • models_root – Package that models.<Alias> resolves against. Defaults to the SDK’s own.

atproto_client.models.models_loader.load_models(package_name: str | None = None) β†’ None

Eagerly import and rebuild every generated model.

Models are imported and built lazily on first access, so calling this is optional. Use it to pay the (one-time) cost up-front instead of on first use, e.g. before forking worker processes or to avoid a latency spike on the first request.

Parameters:

package_name – Models package to load. Defaults to the SDK’s own.