From e28694c987fd1fe860052514d55320f14de021b2 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 9 Mar 2022 02:28:01 -0500 Subject: [PATCH] Remove union operator from more dataclass fields --- .../kt/types/attachment/__init__.py | 8 +++++--- .../kt/types/channel/channel_info.py | 4 ++-- .../kt/types/openlink/open_channel_info.py | 4 +++- matrix_appservice_kakaotalk/kt/types/user/channel_user.py | 4 +++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/matrix_appservice_kakaotalk/kt/types/attachment/__init__.py b/matrix_appservice_kakaotalk/kt/types/attachment/__init__.py index 9854339..0b590cb 100644 --- a/matrix_appservice_kakaotalk/kt/types/attachment/__init__.py +++ b/matrix_appservice_kakaotalk/kt/types/attachment/__init__.py @@ -13,6 +13,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from typing import Optional + from attr import dataclass from mautrix.types import SerializableAttrs @@ -23,9 +25,9 @@ from .mention import MentionStruct @dataclass(kw_only=True) class Attachment(SerializableAttrs): - shout: bool | None = None - mentions: list[MentionStruct] | None = None - urls: list[str] | None = None + shout: Optional[bool] = None + mentions: Optional[list[MentionStruct]] = None + urls: Optional[list[str]] = None @dataclass diff --git a/matrix_appservice_kakaotalk/kt/types/channel/channel_info.py b/matrix_appservice_kakaotalk/kt/types/channel/channel_info.py index e54eabd..afceae0 100644 --- a/matrix_appservice_kakaotalk/kt/types/channel/channel_info.py +++ b/matrix_appservice_kakaotalk/kt/types/channel/channel_info.py @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from typing import Generic, TypeVar +from typing import Generic, TypeVar, Optional from attr import dataclass @@ -48,7 +48,7 @@ class ChannelInfo(Channel): newChatCountInvalid: bool lastChatLogId: Long lastSeenLogId: Long - lastChatLog: Chatlog | None = None + lastChatLog: Optional[Chatlog] = None metaMap: ChannelMetaMap displayUserList: list[DisplayUserInfo] pushAlert: bool diff --git a/matrix_appservice_kakaotalk/kt/types/openlink/open_channel_info.py b/matrix_appservice_kakaotalk/kt/types/openlink/open_channel_info.py index 425a097..3bd3bde 100644 --- a/matrix_appservice_kakaotalk/kt/types/openlink/open_channel_info.py +++ b/matrix_appservice_kakaotalk/kt/types/openlink/open_channel_info.py @@ -13,6 +13,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from typing import Optional + from attr import dataclass from mautrix.types import JSON @@ -25,7 +27,7 @@ from . import OpenTokenComponent, OpenLink @dataclass(kw_only=True) class OpenChannelInfo(ChannelInfo, OpenChannel, OpenTokenComponent): directChannel: bool - openLink: OpenLink | None = None + openLink: Optional[OpenLink] = None @dataclass diff --git a/matrix_appservice_kakaotalk/kt/types/user/channel_user.py b/matrix_appservice_kakaotalk/kt/types/user/channel_user.py index 914e2ac..5b268ce 100644 --- a/matrix_appservice_kakaotalk/kt/types/user/channel_user.py +++ b/matrix_appservice_kakaotalk/kt/types/user/channel_user.py @@ -13,6 +13,8 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +from typing import Optional + from attr import dataclass from mautrix.types import SerializableAttrs @@ -28,7 +30,7 @@ class ChannelUser(SerializableAttrs): @dataclass(kw_only=True) class PartialOpenLinkComponent(SerializableAttrs): """Substitute for Partial""" - linkId: Long | None = None + linkId: Optional[Long] = None @dataclass