intersphinx looks for implementation modules
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
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:
- https://github.com/aio-libs/aiohttp/issues/3714
- https://jira.mongodb.org/browse/MOTOR-338
- https://github.com/tkem/cachetools/issues/178
- https://github.com/AmphoraInc/xarray_mongodb/pull/22
- https://github.com/jonathanslenders/asyncio-redis/issues/143
If a project
- uses xarray, intersphinx, and autodoc
- subclasses any of the classes exposed by
xarray/__init__.pyand documents the new class with the:show-inheritance:flag - 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 xarray module.
Workaround
In conf.py:
import xarray
xarray.DataArray.__module__ = "xarray"
Solution
Put the above hack in xarray/__init__.py
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in xarray/init.py, where public objects are exposed, and compare that behavior with the conf.py workaround described in the issue. Reproduce the Sphinx intersphinx warning for an affected type annotation and verify that the documented public objects resolve to hyperlinks without the warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100