Skip to content
Open
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
7 changes: 5 additions & 2 deletions src/openai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import typing as _t
from typing_extensions import override

from . import types
if _t.TYPE_CHECKING:
from . import types as types
else:
from ._utils._types_proxy import types as types
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given
from ._utils import file_from_path
from ._client import Client, OpenAI, Stream, Timeout, Transport, AsyncClient, AsyncOpenAI, AsyncStream, RequestOptions
Expand Down Expand Up @@ -121,7 +124,7 @@
# openai._exceptions.NotFoundError -> openai.NotFoundError
__locals = locals()
for __name in __all__:
if not __name.startswith("__"):
if not __name.startswith("__") and __name not in ("types", "resources"):
try:
__locals[__name].__module__ = "openai"
except (TypeError, AttributeError):
Expand Down
24 changes: 24 additions & 0 deletions src/openai/_utils/_types_proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from __future__ import annotations

from typing import Any
from typing_extensions import override

from ._proxy import LazyProxy


class TypesProxy(LazyProxy[Any]):
"""A proxy for the `openai.types` module.

This is used so that we can lazily import `openai.types` only when
needed *and* so that users can just import `openai` and reference `openai.types`
"""

@override
def __load__(self) -> Any:
import importlib

mod = importlib.import_module("openai.types")
return mod


types = TypesProxy().__as_proxied__()
Loading