From fbf8cd1a167966d31717f4fc1fec1418910ad0f4 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 26 Oct 2019 00:32:00 +0200 Subject: Fix type errors detected by 'mypy --ignore-missing-imports src'. --- src/ModuleManager.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/ModuleManager.py') diff --git a/src/ModuleManager.py b/src/ModuleManager.py index 36221798..6497129b 100644 --- a/src/ModuleManager.py +++ b/src/ModuleManager.py @@ -1,4 +1,5 @@ -import enum, gc, glob, importlib, io, inspect, os, sys, typing, uuid +import enum, gc, glob, importlib, importlib.util, io, inspect, os, sys +import typing, uuid from src import Config, EventManager, Exports, IRCBot, Logging, Timers, utils class ModuleException(Exception): @@ -155,7 +156,7 @@ class ModuleManager(object): def _module_name(self, path: str) -> str: return os.path.basename(path).rsplit(".py", 1)[0].lower() - def _module_paths(self, name: str) -> str: + def _module_paths(self, name: str) -> typing.List[str]: paths = [] for directory in self.directories: paths.append(os.path.join(directory, name)) @@ -180,7 +181,7 @@ class ModuleManager(object): return getattr(obj, magic) if hasattr(obj, magic) else default def _check_hashflags(self, bot: "IRCBot.Bot", definition: ModuleDefinition - ) -> bool: + ) -> None: for hashflag, value in definition.hashflags: if hashflag == "ignore": # nope, ignore this module. @@ -321,7 +322,7 @@ class ModuleManager(object): def load_modules(self, bot: "IRCBot.Bot", whitelist: typing.List[str]=[], blacklist: typing.List[str]=[] - ) -> typing.Tuple[typing.List[str], typing.List[str]]: + ) -> None: loadable, nonloadable = self._list_valid_modules(bot, whitelist, blacklist) for definition in nonloadable: @@ -388,7 +389,7 @@ class ModuleManager(object): failed = (definition, e) break - if not failed == None: + if failed is not None: for module in self.modules.values(): self._unload_module(module) self.modules = old_modules -- cgit v1.3.1-10-gc9f91