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

Incompatibility with mkdocs 1.2. #295

Closed
coady opened this issue Jun 8, 2021 · 6 comments · Fixed by #294
Closed

Incompatibility with mkdocs 1.2. #295

coady opened this issue Jun 8, 2021 · 6 comments · Fixed by #294
Labels
unconfirmed This bug was not reproduced yet

Comments

@coady
Copy link

coady commented Jun 8, 2021

Describe the bug
The new released mkdocs 1.2 includes livereload, not as a dependency. Resulting in an import error:

  File "/usr/local/lib/python3.9/site-packages/mkdocstrings/plugin.py", line 18, in <module>
    from livereload import Server
ModuleNotFoundError: No module named 'livereload'

To Reproduce
Steps to reproduce the behavior:

  1. pip install mkdocstrings
  2. python -c 'import mkdocstrings.plugin'

Expected behavior
No error.

Information (please complete the following information):

  • mkdocstrings version: 0.15.1
@coady coady added the unconfirmed This bug was not reproduced yet label Jun 8, 2021
@Midnighter
Copy link

To add to this issue, as mentioned in mkdocs/mkdocs#2448 this import error also occurs when running mkdocs build where I would not even expect any live reload feature. Maybe the import could be guarded?

@oprypin
Copy link
Member

oprypin commented Jun 8, 2021

The import just isn't needed whatsoever. But indeed currently it's done always.
See https://github.com/mkdocstrings/mkdocstrings/pull/294/files

@Midnighter
Copy link

I see, it's only for type hints. In that case, one could add the following also:

from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from livereload import Server

def on_serve(self, server: "Server", builder: Callable, **kwargs):

so that livereload would be a dependency for development only.

@oprypin
Copy link
Member

oprypin commented Jun 8, 2021

Sorry, looks like for now a workaround will have to be used, until a new release with the fix can be made.

  • For now, manually add 'livereload' to your list of library requirements
  • Or, pin MkDocs to an older version

@oprypin
Copy link
Member

oprypin commented Jun 9, 2021

The release with the fix is now out.

@themightychris @jaceklaskowski @plannigan @deepcharles @lyz-code @Midnighter @coady @yi2020
(notifying users who linked workarounds from commits elsewhere)

@jaceklaskowski
Copy link

jaceklaskowski commented Jun 10, 2021

Unless I'm doing something completely wrong the latest release of mkdocs-material-insiders mkdocs-material-7.1.7-insiders-2.9.2 theme does not seem to work with serve:

Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 173, in serve_command
    serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 78, in serve
    server = config['plugins'].run_event('serve', server, config=config, builder=builder)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs_macros/plugin.py", line 588, in on_serve
    builder = list(server.watcher._tasks.values())[0]["func"]
AttributeError: 'LiveReloadServer' object has no attribute 'watcher'

What's interesting is that the last line in the stack trace shows no connection to mkdocstrings (and am wondering how this change could change anything)?

It clearly points at mkdocs_macros/plugin.py:588 that looks as follows (can't find the repo to link to):

        # necessary because of a bug in mkdocs:
        # more information in:
        # https://github.com/mkdocs/mkdocs/issues/1952))
        builder = list(server.watcher._tasks.values())[0]["func"]

I'm stuck and am begging for some help.


Right after I posted it I found this. I should've noticed that it's mkdocs_macros_plugin to blame (which I do use along with mkdocs-material). HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed This bug was not reproduced yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants