Closed RussellChamp closed 5 years ago
Looks like this bug would be fixed by doing the work needed to change from imp
to importlib
(#6)
This seems to be an issue with the way reimporting works in general. Still going to change out imp in favor of importlib.
from https://docs.python.org/3/library/importlib.html#importlib.reload
If a module imports objects from another module using
from … import …
, callingreload()
for the other module does not redefine the objects imported from it — one way around this is to re-execute thefrom
statement, another is to useimport
and qualified names (module.name
) instead.
Please change your import statements to work this way as I cannot change this.
Further, if you can't figure out to make it work (since mine still doesn't work), just adding:
import util
reload(util)
doFoo = util.doFoo
or something similar should work (import the module, clear cache, grab what you need of it.
I treat my plugin files as thin shims that just import util methods. Running a !reload against bot commands will reload the plugin file but not plugin dependencies. Eg. I might have "./plugins/foo.py" that contains
from util import doFoo
. Running a !reload will reload "foo.py" but not my "doFoo" module. In order to reload the "doFoo" module, I need to do a full bot restart.Cheers!