From e8eeb1419e2e43a7147a74eb4edcf108c0311354 Mon Sep 17 00:00:00 2001 From: berniehuang2008 Date: Mon, 25 Dec 2023 21:57:22 +0800 Subject: [PATCH] =?UTF-8?q?python3.10=E4=BB=A5=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `str | bytes`这种语法是python3.10的语法,但是还有很多人用的是python3.8,这样就会报错。 使用typing的union是个通用办法,不知道你们的想法怎么样? --- app/util/emoji.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/util/emoji.py b/app/util/emoji.py index dfb276d..ec1cf23 100644 --- a/app/util/emoji.py +++ b/app/util/emoji.py @@ -8,6 +8,8 @@ emoji.py 所以禁止任何人以任何方式修改或间接修改该文件,违者后果自负 """ +from typing import Union + import os import traceback import xml.etree.ElementTree as ET @@ -93,7 +95,7 @@ class Emotion: if lock.locked(): lock.release() - def get_emoji_url(self, md5: str, thumb: bool) -> str | bytes: + def get_emoji_url(self, md5: str, thumb: bool) -> Union[str, bytes]: '''供下载用,返回可能是url可能是bytes''' if thumb: sql = '''