gofile

Module and tool to upload files to gofile.io
git clone https://code.alwayswait.ing/gofile
Log | Files | Refs

commit f62cbb4836d8e7f14eb7767513624d174fd065fd
parent 8849290fa381264fc1e03863be8ee7636cccaacc
Author: archiveanon <>
Date:   Sun, 22 Jun 2025 11:16:56 +0000

Suppress typing-related issues for gofile functions

Diffstat:
Msrc/gofile/api.py | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gofile/api.py b/src/gofile/api.py @@ -78,24 +78,30 @@ class GofileServerResponse(msgspec.Struct, Generic[T]): data: T -async def _gofile_api_get(*args, type: T, **kwargs) -> T: +async def _gofile_api_get(*args, type: type[T], **kwargs) -> T: # performs a GET request and extracts the 'data' property from the response as a given type # if the status is not 'ok', an exception is raised async with httpx.AsyncClient() as client: r = await client.get(*args, **kwargs) - result = msgspec.json.decode(r.text, type=GofileServerResponse[type]) + + # suppress the valid-type error since mypy doesn't cannot use runtime-specialized types + # but msgspec needs to do so + # https://stackoverflow.com/a/59636248 + result = msgspec.json.decode(r.text, type=GofileServerResponse[type]) # type: ignore[valid-type] if result.status != GofileStatus.OK: raise Exception(result) return result.data -async def _gofile_api_post(*args, type: T, **kwargs) -> T: +async def _gofile_api_post(*args, type: type[T], **kwargs) -> T: # performs a POST request and extracts the 'data' property from the response as a given type # if the status is not 'ok', an exception is raised async with httpx.AsyncClient() as client: r = await client.post(*args, **kwargs) - result = msgspec.json.decode(r.text, type=GofileServerResponse[type]) + + # see typing woes at _gofile_api_get + result = msgspec.json.decode(r.text, type=GofileServerResponse[type]) # type: ignore[valid-type] if result.status != GofileStatus.OK: raise Exception(result)