mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(download): add type for callback_name
Just a bit of typo protection in lieu of full type safety for these methods, which is difficult due to the typing of `DownloadEventHandler`.
This commit is contained in:
parent
521f907f58
commit
6cc6a45274
@ -8,7 +8,7 @@ import time
|
|||||||
import traceback
|
import traceback
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from queue import Empty, PriorityQueue
|
from queue import Empty, PriorityQueue
|
||||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Set
|
from typing import TYPE_CHECKING, Any, Dict, List, Literal, Optional, Set
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from pydantic.networks import AnyHttpUrl
|
from pydantic.networks import AnyHttpUrl
|
||||||
@ -528,7 +528,13 @@ class DownloadQueueService(DownloadQueueServiceBase):
|
|||||||
def _execute_cb(
|
def _execute_cb(
|
||||||
self,
|
self,
|
||||||
job: DownloadJob | MultiFileDownloadJob,
|
job: DownloadJob | MultiFileDownloadJob,
|
||||||
callback_name: str,
|
callback_name: Literal[
|
||||||
|
"on_start",
|
||||||
|
"on_progress",
|
||||||
|
"on_complete",
|
||||||
|
"on_cancelled",
|
||||||
|
"on_error",
|
||||||
|
],
|
||||||
excp: Optional[Exception] = None,
|
excp: Optional[Exception] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
if callback := getattr(job, callback_name, None):
|
if callback := getattr(job, callback_name, None):
|
||||||
|
Loading…
Reference in New Issue
Block a user