zulip_bots: Remove fallback code for Python < 3.5.
MODIFY
zulip_bots/zulip_bots/bots/monkeytestit/test_monkeytestit.py
zulip_bots/zulip_bots/bots/monkeytestit/test_monkeytestit.py
from unittest.mock import patch
-from unittest import skipIf
-
-from sys import version_info
from importlib import import_module
from zulip_bots.test_lib import BotTestCase, DefaultTests
-@skipIf(version_info[:2] < (3, 5), "monkeytestit requires python3.5+")
class TestMonkeyTestitBot(BotTestCase, DefaultTests):
bot_name = "monkeytestit"

MODIFY
zulip_bots/zulip_bots/finder.py
zulip_bots/zulip_bots/finder.py
-import sys
+import importlib
+import importlib.util
import os
from typing import Any, Optional, Text, Tuple
from pathlib import Path
@@ -6,25 +7,15 @@ from pathlib import Path
current_dir = os.path.dirname(os.path.abspath(__file__))
def import_module_from_source(path: Text, name: Text) -> Any:
-
- # importlib.util.module_from_spec is supported from Python3.5
- py_version = sys.version_info
- if py_version.major < 3 or (py_version.major == 3 and py_version.minor < 5):
- import imp
- module = imp.load_source(name, path)
- else:
- import importlib.util
spec = importlib.util.spec_from_file_location(name, path)
module = importlib.util.module_from_spec(spec)
loader = spec.loader
if loader is None:
return None
loader.exec_module(module) # type: ignore # FIXME: typeshed issue?
-
return module
def import_module_by_name(name: Text) -> Any:
- import importlib
try:
return importlib.import_module(name)
except ImportError:

zulip_bots: Remove fallback code for Python < 3.5.

Signed-off-by: Anders Kaseorg <anders@zulip.com>