Commit bf5bebb5
Changed files (3)
src/openai/_legacy_response.py
@@ -269,7 +269,9 @@ class LegacyAPIResponse(Generic[R]):
if origin == LegacyAPIResponse:
raise RuntimeError("Unexpected state - cast_to is `APIResponse`")
- if inspect.isclass(origin) and issubclass(origin, httpx.Response):
+ if inspect.isclass(
+ origin # pyright: ignore[reportUnknownArgumentType]
+ ) and issubclass(origin, httpx.Response):
# Because of the invariance of our ResponseT TypeVar, users can subclass httpx.Response
# and pass that class to our request functions. We cannot change the variance to be either
# covariant or contravariant as that makes our usage of ResponseT illegal. We could construct
@@ -279,7 +281,13 @@ class LegacyAPIResponse(Generic[R]):
raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`")
return cast(R, response)
- if inspect.isclass(origin) and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel):
+ if (
+ inspect.isclass(
+ origin # pyright: ignore[reportUnknownArgumentType]
+ )
+ and not issubclass(origin, BaseModel)
+ and issubclass(origin, pydantic.BaseModel)
+ ):
raise TypeError("Pydantic models must subclass our base model type, e.g. `from openai import BaseModel`")
if (
src/openai/_response.py
@@ -214,7 +214,13 @@ class BaseAPIResponse(Generic[R]):
raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`")
return cast(R, response)
- if inspect.isclass(origin) and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel):
+ if (
+ inspect.isclass(
+ origin # pyright: ignore[reportUnknownArgumentType]
+ )
+ and not issubclass(origin, BaseModel)
+ and issubclass(origin, pydantic.BaseModel)
+ ):
raise TypeError("Pydantic models must subclass our base model type, e.g. `from openai import BaseModel`")
if (
requirements-dev.lock
@@ -124,7 +124,7 @@ pygments==2.18.0
# via rich
pyjwt==2.8.0
# via msal
-pyright==1.1.391
+pyright==1.1.392.post0
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.24.0