Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: request iterable #54

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions cozepy/request.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections.abc import Iterable
from typing import (
TYPE_CHECKING,
Any,
Iterable,
Iterator,
List,
Optional,
Expand All @@ -14,7 +14,7 @@
import httpx
from httpx import Response
from pydantic import BaseModel
from typing_extensions import get_args, get_origin
from typing_extensions import get_args

from cozepy.config import DEFAULT_CONNECTION_LIMITS, DEFAULT_TIMEOUT
from cozepy.exception import CozeAPIError, CozePKCEAuthError
Expand Down Expand Up @@ -86,7 +86,7 @@ def request(
if msg in ["authorization_pending", "slow_down", "access_denied", "expired_token"]:
raise CozePKCEAuthError(msg, logid)
raise CozeAPIError(code, msg, logid)
if get_origin(model) is list:
if isinstance(model, Iterable):
item_model = get_args(model)[0]
return [item_model.model_validate(item) for item in data]
else:
Expand Down
Loading