Skip to content

Commit 5322d46

Browse files
authored
Merge pull request #8 from Cvandia/deepsource-autofix-dac214af
refactor: merge collapsible `with` statements
2 parents fc38925 + 33d326e commit 5322d46

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

nonebot_plugin_fishspeech_tts/fish_audio_api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,19 @@ async def generate_tts(self, request: ServeTTSRequest) -> bytes:
149149
if request.references:
150150
self.headers["content-type"] = "application/msgpack"
151151
try:
152-
async with AsyncClient(proxies=self.proxy) as client:
153-
async with client.stream(
152+
async with (
153+
AsyncClient(proxies=self.proxy) as client,
154+
client.stream(
154155
"POST",
155156
self.url,
156157
headers=self.headers,
157158
content=ormsgpack.packb(
158159
request, option=ormsgpack.OPT_SERIALIZE_PYDANTIC
159160
),
160161
timeout=60,
161-
) as resp:
162-
return await resp.aread()
162+
) as resp,
163+
):
164+
return await resp.aread()
163165
except (
164166
ReadTimeout,
165167
ConnectTimeout,

0 commit comments

Comments
 (0)