fix: 使用Union替代类型注解中的管道符号,使python3.9版本不报错

This commit is contained in:
Wangnov
2025-06-30 17:37:02 +08:00
parent 00f423a622
commit 5ecce8e0fe
4 changed files with 37 additions and 29 deletions
+8 -7
View File
@@ -1,23 +1,24 @@
from typing import Union
class ImageMetadata:
def __init__(self, width: int, height: int, filename: str, size: int, url: str, delete_url: str | None = None):
def __init__(self, width: int, height: int, filename: str, size: int, url: str, delete_url: Union[str, None] = None):
self.width = width
self.height = height
self.filename = filename
self.size = size
self.url = url
self.delete_url = delete_url
class UploadResponse:
def __init__(self, success: bool, code: str, message: str, data: ImageMetadata):
self.success = success
self.code = code
self.message = message
self.data = data
class ImageUploader:
def upload(self, file: bytes, filename: str) -> UploadResponse:
raise NotImplementedError