Repository navigation
pyasynq 0.2.0
Typed SDK
Type checkers now see the whole API. The payload and result types come from each handler's signature.
@app.task("email:send", queue="critical")
async def send(email: Email, ctx: TaskContext) -> dict: ...
send # TaskDef[Email, dict]
info = send.enqueue(Email("a@b.c")) # TaskInfo[dict]
await send.wait_result(info) # dict
send.enqueue("a@b.c") # error: expected Email
send.enqueue(email, proces_in=60) # error: unknown option- Added stubs for the Rust extension (
_core.pyi) and apy.typedmarker.TaskInfo,Inspector,Clientand the other Rust-backed classes are now fully typed, andstubtestchecks the stubs against the compiled module. TaskDef[P, R]is generic over the payload and the result. Both@app.taskand@app.task("name", ...)keep these types.- Enqueue and task options are typed (
EnqueueOptionsandTaskOptions), so misspelled or mistyped options are reported. - Task states are
Literaltypes, for example ininspector.list_tasks(queue, "retry"). TaskInfo[R]can be subscripted at runtime.make lintnow runsmypy --strictover the package and a type-assertion test file.
This release changes no runtime behavior.
Install
Download the wheel below (Linux x86_64, CPython ≥ 3.10). On other platforms, build from the source distribution, which needs a Rust toolchain:
pip install pyasynq-0.2.0-cp310-abi3-linux_x86_64.whl