Files
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Has been cancelled
Test / Core Tests (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.10) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.11) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.12) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.13) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.9) (push) Has been cancelled
Test / Full Coverage (Python 3.11) (push) Has been cancelled
Test / Core Provider Tests (OpenAI) (push) Has been cancelled
Test / Core Provider Tests (Anthropic) (push) Has been cancelled
Test / Core Provider Tests (Google) (push) Has been cancelled
Test / Core Provider Tests (Other) (push) Has been cancelled
Test / Anthropic Tests (push) Has been cancelled
Test / Gemini Tests (push) Has been cancelled
Test / Google GenAI Tests (push) Has been cancelled
Test / Vertex AI Tests (push) Has been cancelled
Test / OpenAI Tests (push) Has been cancelled
Test / Writer Tests (push) Has been cancelled
Test / Auto Client Tests (push) Has been cancelled
ty / type-check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00

30 lines
913 B
Python

"""Compatibility helpers for legacy provider import paths."""
from __future__ import annotations
from collections.abc import Iterable
from importlib import import_module
from typing import Any
def resolve_provider_attr(provider: str, modules: Iterable[str], name: str) -> Any:
"""Resolve a legacy provider attribute from the v2 provider package."""
for module_name in modules:
module = import_module(f"instructor.v2.providers.{provider}.{module_name}")
try:
return getattr(module, name)
except AttributeError:
continue
raise AttributeError(
f"module 'instructor.providers.{provider}' has no attribute {name!r}"
)
def make_getattr(provider: str, modules: Iterable[str]):
module_names = tuple(modules)
def __getattr__(name: str) -> Any:
return resolve_provider_attr(provider, module_names, name)
return __getattr__