diff --git a/up2b/up2b_lib/up2b_api/__init__.py b/up2b/up2b_lib/up2b_api/__init__.py index 6b67ccc..c8b074b 100644 --- a/up2b/up2b_lib/up2b_api/__init__.py +++ b/up2b/up2b_lib/up2b_api/__init__.py @@ -160,7 +160,7 @@ def _save_auth_info(self, auth_info: Dict[str, str]): logger.fatal("save auth configure failed", error=e) def _exceed_max_size( - self, images: Tuple[Union[ImageType, DownloadErrorResponse]] + self, images: Tuple[Union[ImageType, DownloadErrorResponse], ...] ) -> Tuple[bool, Optional[str]]: for img in images: if isinstance(img, DownloadErrorResponse): @@ -173,7 +173,7 @@ def _exceed_max_size( return False, None def _check_images_valid( - self, images: Tuple[Union[ImageType, DownloadErrorResponse]] + self, images: Tuple[Union[ImageType, DownloadErrorResponse], ...] ): """ Check if all images exceed the max size or can be compressed diff --git a/up2b/up2b_lib/up2b_api/__init__.pyi b/up2b/up2b_lib/up2b_api/__init__.pyi index 4808a98..e5a8cda 100644 --- a/up2b/up2b_lib/up2b_api/__init__.pyi +++ b/up2b/up2b_lib/up2b_api/__init__.pyi @@ -66,6 +66,8 @@ class ImageBedAbstract(ABC): @abstractmethod def description(self) -> str: ... +Images = Tuple[Union[ImageType, DownloadErrorResponse], ...] + class Base: image_bed_code: ImageBedCode max_size: int @@ -89,12 +91,8 @@ class Base: def check_login(self) -> None: ... def _read_auth_info(self) -> Optional[AuthInfo]: ... def _save_auth_info(self, auth_info: Dict[str, str]) -> None: ... - def _exceed_max_size( - self, images: Tuple[Union[ImageType, DownloadErrorResponse]] - ) -> Tuple[bool, Optional[str]]: ... - def _check_images_valid( - self, images: Tuple[Union[ImageType, DownloadErrorResponse]] - ): ... + def _exceed_max_size(self, images: Images) -> Tuple[bool, Optional[str]]: ... + def _check_images_valid(self, images: Images): ... def _compress_image(self, image: ImageType) -> ImageType: ... def _add_watermark(self, image_path: ImagePath) -> ImagePath: ... def _clear_cache(self) -> None: ... diff --git a/up2b/up2b_lib/utils.py b/up2b/up2b_lib/utils.py index 65f6435..773631d 100644 --- a/up2b/up2b_lib/utils.py +++ b/up2b/up2b_lib/utils.py @@ -42,7 +42,7 @@ def timeout() -> float: return DEFAULT_TIMEOUT -def check_image_exists(images: Tuple[Union[ImageType, DownloadErrorResponse]]): +def check_image_exists(images: Tuple[Union[ImageType, DownloadErrorResponse], ...]): for image in images: if isinstance(image, Path) and not image.exists(): raise FileNotFoundError(image)