pydata / pydata/xarray

intersphinx looks for implementation modules

Open Beginner friendly
#4,279 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-documentation
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:

If a project

  1. uses xarray, intersphinx, and autodoc
  2. subclasses any of the classes exposed by xarray/__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 xarray module.

Workaround

In conf.py:

import xarray
xarray.DataArray.__module__ = "xarray"

Solution

Put the above hack in xarray/__init__.py

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.