From b4fd7c2080f2c3f2af6f215705083368ceef18d8 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Mon, 16 Oct 2023 16:41:23 -0700 Subject: [PATCH] more type checking imports --- wiki_postbot/interfaces/mediawiki.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/wiki_postbot/interfaces/mediawiki.py b/wiki_postbot/interfaces/mediawiki.py index b276eba..490e3d0 100644 --- a/wiki_postbot/interfaces/mediawiki.py +++ b/wiki_postbot/interfaces/mediawiki.py @@ -13,11 +13,19 @@ from wiki_postbot.actions import Result from wiki_postbot.logger import init_logger from datetime import datetime import requests -from discord.message import Message, Embed + import pdb if TYPE_CHECKING: - from wiki_postbot.clients.slack import SlackMessage + try: + from wiki_postbot.clients.slack import SlackMessage + except ImportError: + SlackMessage = None + try: + from discord.message import Message, Embed + except ImportError: + Message = None + Embed = None # creds = Mediawiki_Creds.from_json('mediawiki_creds.json') @@ -153,7 +161,7 @@ class Wiki: ) return result - def handle_discord(self, msg:Message) -> Result: + def handle_discord(self, msg:'Message') -> Result: """ Not being precious about this, just implementing and will worry about generality later!