Symptoms
When you're developing an add-on existing out of multiple files on a disk, you want to reload your add-on many times to include the changes you made.
This works fine when you make a modification in __init__.py and call bpy.ops.preferences.addon_enable(module='your_module'), as you will see: "module changed on disk: 'path/to/file.py' reloading...".
However, if you make a change in another module, e.g. your_module_props.py, and call addon_enable(), nothing is triggered. You will only see {'FINISHED'}.
If you afterwards make a change to __init__.py, the previous changes you made to your_module_props.py are seen by Blender this time when you call addon_enable().
Likely culprit
I believe the culprit is here: https://developer.blender.org/diffusion/B/browse/master/release/scripts/modules/addon_utils.py$325
mtime_orig = getattr(mod, "__time__", 0) mtime_new = os.path.getmtime(mod.__file__) # only checks __init__.py if mtime_orig != mtime_new:
These lines of code only check if the main file (__init__.py) has changed.
Possible solutions
One of the following:
- Extend the check to check if any (Python) file of an add-on has changed.
- Remove the check if files changed, and always trigger the reload.
Importance
Any medium/large add-on that follows proper code conventions to prevent spaghetti code will use multiple files. This limited check to only __init__.py severely slows down app development, as we cannot do a quick reload. Instead we have to make a minimal change to __init__.py to trigger the reload, or restart Blender every time we have made a code modification.