Further clarification of type hints in ModuleManager.py, including now making it

explicit that module objects MUST inherit from BaseModule
This commit is contained in:
jesopo 2018-12-02 16:00:55 +00:00
parent 9466f57efc
commit 9dd9111f85

View file

@ -19,6 +19,7 @@ class ModuleNotLoadedWarning(ModuleWarning):
pass
class BaseModule(object):
_context = ""
def __init__(self,
bot: "IRCBot.Bot",
events: EventManager.EventHook,
@ -33,6 +34,8 @@ class BaseModule(object):
self.on_load()
def on_load(self):
pass
def unload(self):
pass
class ModuleManager(object):
def __init__(self,
@ -49,8 +52,8 @@ class ModuleManager(object):
self.log = log
self.directory = directory
self.modules = {}
self.waiting_requirement = {}
self.modules = {} # type: typing.Dict[str, BaseModule]
self.waiting_requirement = {} # type: typing.Dict[str, typing.Set[str]]
def list_modules(self) -> typing.List[str]:
return sorted(glob.glob(os.path.join(self.directory, "*.py")))