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

intersphinx looks for implementation modules #143

Open
crusaderky opened this issue Jul 28, 2020 · 0 comments
Open

intersphinx looks for implementation modules #143

crusaderky opened this issue Jul 28, 2020 · 0 comments

Comments

@crusaderky
Copy link
Contributor

This is a widespread issue caused by the pattern of defining objects in private module and then exposing them to the final user by importing them in the top-level __init__.py, vs. how intersphinx works.

Exact same issue in different projects:

If a project

  1. uses asyncio_redis, intersphinx, and autodoc
  2. subclasses any of the classes exposed by asyncio_redis/__init__.py and documents the new class with the :show-inheritance: flag
  3. Starting from Sphinx 3, has any of the above classes anywhere in a type annotation

Then Sphinx emits a warning and fails to create a hyperlink, because intersphinx uses the __module__ attribute to look up the object in objects.inv, but __module__ points to the implementation module while objects.inv points to the top-level module.

Workaround

In conf.py:

import asyncio_redis
asyncio_redis.Pool.__module__ = "asyncio_redis"

Solution

Put the above hack in asyncio_redis/__init__.py

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

No branches or pull requests

1 participant