From ae4d610754b0f32bda0dc87536c22f493124a81d Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 16 Oct 2023 16:37:33 -0700 Subject: [PATCH] dont import discord message for type checking --- wiki_postbot/templates/wiki.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wiki_postbot/templates/wiki.py b/wiki_postbot/templates/wiki.py index 05fcda1..bac0df9 100644 --- a/wiki_postbot/templates/wiki.py +++ b/wiki_postbot/templates/wiki.py @@ -4,16 +4,20 @@ Templates for representing different kinds of messages on mediawiki from typing import TYPE_CHECKING from wiki_postbot.formats.wiki import WikiPage from abc import abstractmethod -from discord.message import Message + import warnings if TYPE_CHECKING: from wiki_postbot.clients.slack import SlackMessage + try: + from discord.message import Message + except ImportError: + Message = None class WikiTemplate(WikiPage): @abstractmethod - def format_discord(self, msg:Message) -> str: + def format_discord(self, msg:'Message') -> str: """ Format a discord message into a template string """ @@ -21,7 +25,7 @@ class WikiTemplate(WikiPage): class TemplateMessage(WikiTemplate): @classmethod - def format_discord(self, msg:Message) -> str: + def format_discord(self, msg:'Message') -> str: # try/catch the avatar URL try: avatar = msg.author.avatar.url