Nicholas
05/29/2023, 2:04 PMtaskmypyNicholas
05/29/2023, 2:05 PMfrom typing import Any, cast
import httpx
from prefect import flow, task
@task(retries=3)
def call(url: str) -> dict[str, Any]:
    response = httpx.get(url)
    if response.status_code >= 400:
        raise Exception()
    return cast(dict[str, Any], response.json())
@task
def parse(response: dict[str, Any]) -> str:
    return cast(str, response["fact"])
@flow
def run_demo_prefect(url: str) -> None:
    fact_response = call(url)
    parse(fact_response)
if __name__ == "__main__":
    run_demo_prefect("<https://catfact.ninja/fact>")Nicholas
05/29/2023, 2:05 PMmypyexample.py:23: error: No overload variant of "__call__" of "Task" matches argument type "None"  [call-overload]
example.py:23: note: Possible overload variants:
example.py:23: note:     def __call__(self, response: Dict[str, Any]) -> None
example.py:23: note:     def __call__(self, response: Dict[str, Any]) -> str
example.py:23: note:     def __call__(self, *args: Any, return_state: Literal[True], **kwargs: Any) -> State[str]Nicholas
05/29/2023, 2:06 PMDiego Escobedo
07/12/2023, 5:34 PMNate
07/25/2023, 11:23 PM❯ mypy mypytest.py --follow-imports skip
Success: no issues found in 1 source fileNicholas
08/04/2023, 9:29 AMNicholas
08/04/2023, 9:29 AM