Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module import #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix module import #6

wants to merge 1 commit into from

Conversation

kdeldycke
Copy link
Contributor

In some circumstances, the patch introduced in #3 and #4 will fail with the following error:

Traceback (most recent call last):
  File "/home/runner/work/workflows/workflows/.venv/bin/mdformat", line 5, in <module>
    from mdformat.__main__ import run
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat/__init__.py", line 4, in <module>
    from mdformat._api import file, text
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat/_api.py", line 10, in <module>
    from mdformat._util import EMPTY_MAP, NULL_CTX, build_mdit, detect_newline_type
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat/_util.py", line 12, in <module>
    import mdformat.plugins
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat/plugins.py", line 60, in <module>
    PARSER_EXTENSIONS: Mapping[str, ParserExtensionInterface] = _load_parser_extensions()
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat/plugins.py", line 57, in _load_parser_extensions
    return {ep.name: ep.load() for ep in parser_extension_entrypoints}
                     ^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/importlib/metadata/__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.5/x64/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat_pelican/__init__.py", line 3, in <module>
    from .plugin import RENDERERS, update_mdit  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/workflows/workflows/.venv/lib/python3.12/site-packages/mdformat_pelican/plugin.py", line 144, in <module>
    mdformat_gfm.plugin.RENDERERS["link"] = _patch_gfm_link_renderer
    ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'mdformat_gfm' has no attribute 'plugin'

(Source: https://github.com/kdeldycke/workflows/actions/runs/10520430679/job/29149370480#step:9:15 )

This is a simple patch to fix this issue by being mode specific about the import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant