{{ message }}
Reload hook modules when config reloads#4141
Open
marko1olo wants to merge 1 commit into
Open
Conversation
3133b14 to
6c96acf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #3993.
mkdocs servereloads the configuration for rebuilds, but hook modules were cached byHooks._load_hook(). If a watched hook file changed, the subsequent config validation reused the old module object instead of executing the updated hook file.This removes the cross-validation cache for hook modules and executes the current hook source on each config load, while preserving the existing module metadata,
sys.modulesregistration, and temporary hook-directorysys.pathhandling. The regression test also covers a same-size/same-mtime rewrite so reloads are not dependent on Python bytecode-cache freshness.Tests run:
python -m unittest mkdocs.tests.config.config_options_tests.HooksTest.test_hooks_reload_when_file_changespython -m unittest mkdocs.tests.config.config_options_tests.HooksTestpython -m unittest mkdocs.tests.config.config_options_testspython -m unittest mkdocs.tests.config.config_options_legacy_tests.HooksTestpython -m unittest discover -s mkdocs\tests\config -p "*_tests.py"ruff check mkdocs\config\config_options.py mkdocs\tests\config\config_options_tests.pypython -X utf8 -m isort --check-only --diff mkdocs\config\config_options.py mkdocs\tests\config\config_options_tests.pypython -X utf8 -m black --workers 1 -q --check --diff --line-ranges 1-8 --line-ranges 1186-1208 mkdocs\config\config_options.pypython -X utf8 -m black --workers 1 -q --check --diff --line-ranges 2374-2406 mkdocs\tests\config\config_options_tests.pygit diff --check