Skip to content

🐛 FIX RemovedInSphinx10Warning for inventory item iteration#1129

Merged
chrisjsewell merged 3 commits intomasterfrom
fix-warning
May 7, 2026
Merged

🐛 FIX RemovedInSphinx10Warning for inventory item iteration#1129
chrisjsewell merged 3 commits intomasterfrom
fix-warning

Conversation

@chrisjsewell
Copy link
Copy Markdown
Member

Fixes the deprecation warning from Sphinx >= 8.2:

RemovedInSphinx10Warning: The iter() interface for _InventoryItem objects is deprecated.
Please access the `project_name`, `project_version`, `uri`, and `displayname` attributes directly.

The previous code unpacked _InventoryItem as a tuple (project, version, loc, text = data[target]), which triggers the warning.

This uses hasattr to detect whether the new attribute-based API is available and falls back to tuple unpacking for older Sphinx versions. This approach is more robust than version checking (cf. #1079 which used sphinx.__version_info__ — an attribute that doesn't exist; the correct attribute is sphinx.version_info).

Note: the correct attribute name on _InventoryItem is display_name (with underscore), despite the warning message saying displayname.

Fixes the deprecation warning from Sphinx >= 8.2:

```
RemovedInSphinx10Warning: The iter() interface for _InventoryItem objects is deprecated.
Please access the `project_name`, `project_version`, `uri`, and `displayname` attributes directly.
```

The previous code unpacked `_InventoryItem` as a tuple (`project, version, loc, text = data[target]`), which triggers the warning.

This uses `hasattr` to detect whether the new attribute-based API is available and falls back to tuple unpacking for older Sphinx versions. This approach is more robust than version checking (cf. #1079 which used `sphinx.__version_info__` — an attribute that doesn't exist; the correct attribute is `sphinx.version_info`).

Note: the correct attribute name on `_InventoryItem` is `display_name` (with underscore), despite the warning message saying `displayname`.
@chrisjsewell chrisjsewell linked an issue May 7, 2026 that may be closed by this pull request
@chrisjsewell chrisjsewell merged commit 6fac4d0 into master May 7, 2026
22 checks passed
@chrisjsewell chrisjsewell deleted the fix-warning branch May 7, 2026 20:02
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

Successfully merging this pull request may close these issues.

sphinx 8.2 deprecation warning _InventoryItem.__iter__

1 participant