Skip to content

Commit d930d81

Browse files
fix client tests types
1 parent da7a086 commit d930d81

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/py/sdk/src/context7/client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import os
66
import warnings
7-
from typing import Literal, overload
7+
from typing import Any, Literal, overload
88

99
from context7.errors import Context7Error, Context7ValidationError
10-
from context7.http import HttpClient
10+
from context7.http import HttpClient, TxtResponseHeaders
1111
from context7.models import (
1212
CodeDocsResponse,
1313
InfoDocsResponse,
@@ -79,8 +79,8 @@ def _build_docs_request(
7979

8080

8181
def _process_docs_response(
82-
result: str | dict,
83-
headers: object | None,
82+
result: str | dict[str, Any],
83+
headers: TxtResponseHeaders | None,
8484
mode: Literal["info", "code"],
8585
format: Literal["json", "txt"], # pylint: disable=redefined-builtin
8686
) -> TextDocsResponse | CodeDocsResponse | InfoDocsResponse:
@@ -93,8 +93,10 @@ def _process_docs_response(
9393
hasNext=headers.has_next if headers else False,
9494
hasPrev=headers.has_prev if headers else False,
9595
)
96+
# When format is "txt", result is always a string from the HTTP response
97+
content = result if isinstance(result, str) else ""
9698
return TextDocsResponse(
97-
content=result,
99+
content=content,
98100
pagination=pagination,
99101
totalTokens=headers.total_tokens if headers else 0,
100102
)

0 commit comments

Comments
 (0)