Skip to content

autotypes: stop using the deprecated tuple interface of intersphinx inventory items (RemovedInSphinx10Warning) #556

Closed

Description

@jonathansick

Noticed while working on #554 / #555. Not a failure today, but it becomes one with Sphinx 10.

Symptom

Builds and tests that resolve a reference through documenteer.ext.autotypes.xrefs's intersphinx fallback emit, on Sphinx 8.2 and later:

src/documenteer/ext/autotypes/xrefs.py:879: RemovedInSphinx10Warning: The tuple interface for _InventoryItem objects is deprecated. Please access the `project_name`, `project_version`, `uri`, and `displayname` attributes directly.
  return make(cast("str", entries[name][2]))
src/documenteer/ext/autotypes/xrefs.py:914: RemovedInSphinx10Warning: The tuple interface for _InventoryItem objects is deprecated. Please access the `project_name`, `project_version`, `uri`, and `displayname` attributes directly.
  uri = cast("str", entries[name][2])

The test suite shows it in tests/ext/autotypes_test.py::test_autotypes_inherited_docstring_links, and a plain sphinx-build of tests/roots/test-autotypes-inherited prints it too.

Where

Both uses are in src/documenteer/ext/autotypes/xrefs.py (line numbers as of #555):

  • _resolve_intersphinx, line 879: entries[name][2]
  • _intersphinx_terminal_index, line 914: entries[name][2]

Index 2 is the item's URI. A grep of src/ for ][2] finds no other uses.

Constraint on the fix

pyproject.toml declares Sphinx>=8,<10. The _InventoryItem class with a .uri attribute exists in Sphinx 8.2.3 and 9.x (checked in the nox environments), but I did not check Sphinx 8.0 and 8.1, where inventory entries may still be plain tuples. So the fix is one of:

  • read .uri when the item has it and fall back to [2] otherwise, or
  • raise the Sphinx floor to a release where .uri is always present, and use .uri directly.

Either way the cast("str", ...) around the access can probably go once .uri is used.

To do

  • Check whether Sphinx 8.0 / 8.1 inventory entries have a .uri attribute, and pick one of the two approaches above
  • Replace both entries[name][2] accesses
  • Confirm the warning is gone on the Sphinx 9 and Sphinx dev test sessions (the dev session is where removal will first show up as an error)
  • Before widening the dependency to Sphinx 10, grep for other RemovedInSphinx10Warning sources in the test output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions