chore(pre-commit): fix mdformat hook by adding gfm plugin and pinning markdown-it-py<3.0.0 #4056
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.
chore(pre-commit): fix mdformat hook by adding gfm plugin and pinning markdown-it-py<3.0.0
Explanation
The
mdformatpre-commit hook was failing on pre-commit.ci with:This originates from the GFM autolink plugin expecting the
linkifyrule, which was not registered due to a plugin / dependency mismatch after upstreammarkdown-it-py3.x changes. The hook environment (without explicit GFM + version pin) pulled a newer combination that broke the plugin ordering.Root Cause
mdformatalone does not bundle GitHub-Flavored Markdown extensions.mdformat-gfmmust be explicitly added toadditional_dependenciesto enable GFM extensions (including autolink behavior).markdown-it-pyreleases changed internals causing thegfm_autolinkplugin to try to insert before a rule that no longer exists in that form.markdown-it-pyversion, triggering the KeyError.Changes
mdformat-gfm==0.3.5toadditional_dependencies.markdown-it-py<3.0.0to ensure compatibility with the currentmdformat-gfmplugin.mdformat_frontmatterdependency intact.Reproduction (Before Fix)
(Reference prior failed CI run logs showing the KeyError; can be reproduced by removing the added dependencies and running:)
Result before fix: traceback with
KeyError: 'Parser rule not found: linkify'.Verification (After Fix)
Result:
mdformat....................................PassedAlso validated full
pre-commit run --all-filessucceeds for the mdformat stage locally.Notes
black;isortcontinues to manage import style.markdown-it-pypin once upstreammdformat-gfmdeclares compatibility with 3.x.Future Cleanup
Periodically test removing the pin:
If it still passes, the pin can be dropped.
Checklist