LukeCarrier / mkdocs-drawio-exporter

Exports your Draw.io diagrams at build time for easier embedding into your documentation
https://pypi.org/project/mkdocs-drawio-exporter/
MIT License
81 stars 9 forks source link

`SyntaxError: f-string: unmatched '['` with 0.9.0 release #59

Closed mriedem closed 6 months ago

mriedem commented 6 months ago

We're seeing this in a build with mkdocs-drawio-exporter 0.9.0 which wasn't an issue before:

Traceback (most recent call last):

  File "/home/travis/virtualenv/python3.9.18/bin/mkdocs", line 8, in <module>

    sys.exit(cli())

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/click/core.py", line 829, in __call__

    return self.main(*args, **kwargs)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/click/core.py", line 782, in main

    rv = self.invoke(ctx)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/click/core.py", line 1259, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/click/core.py", line 1066, in invoke

    return ctx.invoke(self.callback, **ctx.params)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/click/core.py", line 610, in invoke

    return callback(*args, **kwargs)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/__main__.py", line 283, in build_command

    cfg = config.load_config(**kwargs)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/base.py", line 378, in load_config

    errors, warnings = cfg.validate()

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/base.py", line 230, in validate

    run_failed, run_warnings = self._validate()

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/base.py", line 188, in _validate

    self[key] = config_option.validate(value)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 182, in validate

    return self.run_validation(value)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 1064, in run_validation

    self.load_plugin_with_namespace(name, cfg)

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 1102, in load_plugin_with_namespace

    return (name, self.load_plugin(name, config))

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs/config/config_options.py", line 1120, in load_plugin

    plugin_cls = self.installed_plugins[name].load()

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 184, in load

    module = import_module(match.group('module'))

  File "/opt/python/3.9.18/lib/python3.9/importlib/__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import

  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked

  File "<frozen importlib._bootstrap_external>", line 850, in exec_module

  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs_drawio_exporter/__init__.py", line 1, in <module>

    from .exporter import DrawIoExporter, Source

  File "/home/travis/virtualenv/python3.9.18/lib/python3.9/site-packages/mkdocs_drawio_exporter/exporter.py", line 271

    img_src = f"{filename}-{page_index}.{config["format"]}"

                                                 ^

SyntaxError: f-string: unmatched '['

I'm not sure if the part of the 0.9.0 changelog which says Fix handling of diagram filenames containing spaces could be causing problems here, but none of the *.drawio files in our docs tree have spaces in the names.

This is the plugin config in our mkdocs.yaml file:

    - drawio-exporter:
        embed_format: '<object type="image/svg+xml" data="{img_src}"></object>'

These are the installed packages in the environment:

GitPython-3.1.43 babel-2.14.0 charset-normalizer-3.3.2 click-8.1.7 colorama-0.4.6 ghp-import-2.1.0 gitdb-4.0.11 idna-3.7 importlib-metadata-7.1.0 jinja2-3.1.3 livereload-2.6.3 markdown-3.6 markupsafe-2.1.5 mergedeep-1.3.4 mkdocs-1.5.3 mkdocs-drawio-exporter-0.9.0 mkdocs-git-revision-date-localized-plugin-1.2.4 mkdocs-literate-nav-0.6.1 mkdocs-macros-plugin-1.0.5 mkdocs-material-9.5.18 mkdocs-material-extensions-1.3.1 mkdocs-redirects-1.2.1 paginate-0.5.6 pathspec-0.12.1 plantuml-markdown-3.9.4 pygments-2.17.2 pymdown-extensions-10.8 python-dateutil-2.9.0.post0 pytz-2024.1 pyyaml-6.0.1 pyyaml-env-tag-0.1 regex-2024.4.16 requests-2.31.0 six-1.16.0 smmap-5.0.1 termcolor-2.4.0 tornado-6.4 urllib3-2.2.1 watchdog-4.0.0 zipp-3.18.1

LukeCarrier commented 6 months ago

Released in v0.9.1; sorry about this!