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:
parent
9466f57efc
commit
9dd9111f85
1 changed files with 5 additions and 2 deletions
|
@ -19,6 +19,7 @@ class ModuleNotLoadedWarning(ModuleWarning):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class BaseModule(object):
|
class BaseModule(object):
|
||||||
|
_context = ""
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
bot: "IRCBot.Bot",
|
bot: "IRCBot.Bot",
|
||||||
events: EventManager.EventHook,
|
events: EventManager.EventHook,
|
||||||
|
@ -33,6 +34,8 @@ class BaseModule(object):
|
||||||
self.on_load()
|
self.on_load()
|
||||||
def on_load(self):
|
def on_load(self):
|
||||||
pass
|
pass
|
||||||
|
def unload(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class ModuleManager(object):
|
class ModuleManager(object):
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
@ -49,8 +52,8 @@ class ModuleManager(object):
|
||||||
self.log = log
|
self.log = log
|
||||||
self.directory = directory
|
self.directory = directory
|
||||||
|
|
||||||
self.modules = {}
|
self.modules = {} # type: typing.Dict[str, BaseModule]
|
||||||
self.waiting_requirement = {}
|
self.waiting_requirement = {} # type: typing.Dict[str, typing.Set[str]]
|
||||||
|
|
||||||
def list_modules(self) -> typing.List[str]:
|
def list_modules(self) -> typing.List[str]:
|
||||||
return sorted(glob.glob(os.path.join(self.directory, "*.py")))
|
return sorted(glob.glob(os.path.join(self.directory, "*.py")))
|
||||||
|
|
Loading…
Reference in a new issue