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

[insiders] AttributeError: 'TagsPlugin' object has no attribute 'tags_mapping' #3839

Closed
4 of 5 tasks
twardoch opened this issue Apr 24, 2022 · 3 comments
Closed
4 of 5 tasks

Comments

@twardoch
Copy link
Contributor

@twardoch twardoch commented Apr 24, 2022

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

When I build a doc where an .md contains:

---
tags:
  - importing
  - install

---

with mkdocs-material-8.2.10-insiders-4.13.0, I get a fail:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.10/3.10.2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/mkdocs/__main__.py", line 236, in <module>
    cli()
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/mkdocs/__main__.py", line 192, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/mkdocs/commands/build.py", line 314, in build
    _build_page(file.page, config, doc_files, nav, env, dirty)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/mkdocs/commands/build.py", line 212, in _build_page
    context = config['plugins'].run_event(
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/mkdocs/plugins.py", line 102, in run_event
    result = method(item, **kwargs)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/material/plugins/tags/plugin.py", line 89, in on_page_context
    context["tags"] = [
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/material/plugins/tags/plugin.py", line 90, in <listcomp>
    self.__render_tag(tag)
  File "/Users/adam/Library/Python/3.10/lib/python/site-packages/material/plugins/tags/plugin.py", line 126, in __render_tag
    type = self.tags_mapping.get(tag)
AttributeError: 'TagsPlugin' object has no attribute 'tags_mapping'

Upon looking at the source code of the newest tags/plugin.py, it does look fishy. I can see how tags_mapping may not get assigned, but then the .get() method does not provide a fallback.

Expected behaviour

No fail when using the tags plugin

Actual behaviour

Fail in the newest mkdocs-material-8.2.10-insiders-4.13.0 (was OK in previous)

Steps to reproduce

Use the tags plugin with a simple .md file that contains some tags in the metadata

Package versions

  • Python 3.10.2
  • mkdocs, version 1.3.0
  • Material: Version: 8.2.10+insiders.4.13.0

Configuration

plugins:
  - search
  - monorepo
  - awesome-pages:
      filename: pages.yml
      collapse_single_pages: true
      strict: false
  - tags:
      tags_file: tags.md


### System information

- Operating system: macOS 12.3
- Browser: Chrome
@squidfunk
Copy link
Owner

@squidfunk squidfunk commented Apr 24, 2022

Thanks for reporting. I'm having a hard time reproducing this. Does this fix it?

pip install -e <path to insiders folder>

@squidfunk
Copy link
Owner

@squidfunk squidfunk commented Apr 24, 2022

Ah, think I found the error. Fixed in master of Insiders, can you confirm?

@squidfunk
Copy link
Owner

@squidfunk squidfunk commented Apr 25, 2022

I'm pretty confident this was fixed in the latest commit. I just released 8.2.11+insiders-4.13.1 which contains the fix. In case the issue persists, please reopen.

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

No branches or pull requests

2 participants