Skip to content

Commit ab5c493

Browse files
chore(internal): codegen related update
1 parent 875138a commit ab5c493

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ managed = true
4646
# version pins are in requirements-dev.lock
4747
dev-dependencies = [
4848
"pyright==1.1.399",
49-
"mypy",
49+
"mypy==1.17",
5050
"respx",
5151
"pytest",
5252
"pytest-asyncio",

requirements-dev.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mdurl==0.1.2
7272
multidict==6.4.4
7373
# via aiohttp
7474
# via yarl
75-
mypy==1.14.1
75+
mypy==1.17.0
7676
mypy-extensions==1.0.0
7777
# via mypy
7878
nodeenv==1.8.0
@@ -81,6 +81,8 @@ nox==2023.4.22
8181
packaging==23.2
8282
# via nox
8383
# via pytest
84+
pathspec==0.12.1
85+
# via mypy
8486
platformdirs==3.11.0
8587
# via virtualenv
8688
pluggy==1.5.0

requirements.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ multidict==6.4.4
5555
propcache==0.3.1
5656
# via aiohttp
5757
# via yarl
58-
pydantic==2.11.9
58+
pydantic==2.12.5
5959
# via opencode-ai
60-
pydantic-core==2.33.2
60+
pydantic-core==2.41.5
6161
# via pydantic
6262
sniffio==1.3.0
6363
# via anyio
6464
# via opencode-ai
65-
typing-extensions==4.12.2
65+
typing-extensions==4.15.0
6666
# via anyio
6767
# via multidict
6868
# via opencode-ai
6969
# via pydantic
7070
# via pydantic-core
7171
# via typing-inspection
72-
typing-inspection==0.4.1
72+
typing-inspection==0.4.2
7373
# via pydantic
7474
yarl==1.20.0
7575
# via aiohttp

src/opencode_ai/_streaming.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ def __stream__(self) -> Iterator[_T]:
5454
process_data = self._client._process_response_data
5555
iterator = self._iter_events()
5656

57-
for sse in iterator:
58-
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
59-
60-
# As we might not fully consume the response stream, we need to close it explicitly
61-
response.close()
57+
try:
58+
for sse in iterator:
59+
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
60+
finally:
61+
# Ensure the response is closed even if the consumer doesn't read all data
62+
response.close()
6263

6364
def __enter__(self) -> Self:
6465
return self
@@ -117,11 +118,12 @@ async def __stream__(self) -> AsyncIterator[_T]:
117118
process_data = self._client._process_response_data
118119
iterator = self._iter_events()
119120

120-
async for sse in iterator:
121-
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
122-
123-
# As we might not fully consume the response stream, we need to close it explicitly
124-
await response.aclose()
121+
try:
122+
async for sse in iterator:
123+
yield process_data(data=sse.json(), cast_to=cast_to, response=response)
124+
finally:
125+
# Ensure the response is closed even if the consumer doesn't read all data
126+
await response.aclose()
125127

126128
async def __aenter__(self) -> Self:
127129
return self

0 commit comments

Comments
 (0)