Skip to content

Commit

Permalink
refactor: Fix type hints and variable references in gpytranslate
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideGalilei committed Dec 3, 2024
1 parent 7375acd commit ea857df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions gpytranslate/gpytranslate.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async def translate(
client: httpx.AsyncClient
raw: Union[Mapping, List] = (
(
await c.post(
await client.post(
self.url,
params={**params, "q": text},
headers=self.get_headers(),
Expand All @@ -159,7 +159,7 @@ async def translate(
else (
{
k: (
await c.post(
await client.post(
self.url,
params={**params, "q": v},
headers=self.get_headers(),
Expand All @@ -170,7 +170,7 @@ async def translate(
if isinstance(text, Mapping)
else [
(
await c.post(
await client.post(
self.url,
params={**params, "q": elem},
headers=self.get_headers(),
Expand All @@ -180,7 +180,7 @@ async def translate(
]
)
)
await c.aclose()
await client.aclose()

return self.check(raw=raw, client=client, dt=dt, text=text)
except Exception as e:
Expand Down Expand Up @@ -238,11 +238,11 @@ async def tts(
) as resp:
resp: httpx.Response
if isinstance(file, io.BytesIO):
async for chunk in response.aiter_bytes(chunk_size=chunk_size):
async for chunk in resp.aiter_bytes(chunk_size=chunk_size):
file.write(chunk)
else:
file: AsyncBufferedIOBase
async for chunk in response.aiter_bytes(chunk_size=chunk_size):
async for chunk in resp.aiter_bytes(chunk_size=chunk_size):
await file.write(chunk)
await c.aclose()

Expand Down
2 changes: 1 addition & 1 deletion gpytranslate/types/base_translator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Mapping
from typing import Any, Callable, Dict, List, Union
from typing import Any, Callable, Dict, List, Optional, Union

from .translated_object import TranslatedObject

Expand Down

0 comments on commit ea857df

Please sign in to comment.