Skip to content

InventoryItem deprecation warning since Sphinx 8.2.0 #173

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

Closed
mgeier opened this issue Feb 17, 2025 · 7 comments
Closed

InventoryItem deprecation warning since Sphinx 8.2.0 #173

mgeier opened this issue Feb 17, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@mgeier
Copy link
Contributor

mgeier commented Feb 17, 2025

Issue

I have tested the upcoming Sphinx version (using Sphinx 8.2.0rc1) and got this warning:

 Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/sphinx_codeautolink/extension/__init__.py", line 46, in wrapper
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/sphinx_codeautolink/extension/__init__.py", line 180, in create_references
    self.inventory = self.make_inventory(app)
                     ~~~~~~~~~~~~~~~~~~~^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/sphinx_codeautolink/extension/__init__.py", line 169, in make_inventory
    transposed = transpose_inventory(inter_inv, relative_to=app.outdir)
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/sphinx_codeautolink/extension/__init__.py", line 301, in transpose_inventory
    location = info[2]
               ~~~~^^^
  File "/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/sphinx/util/inventory.py", line 313, in __getitem__
    warnings.warn(
    ~~~~~~~~~~~~~^
        'The tuple interface for _InventoryItem objects is deprecated.',
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        RemovedInSphinx10Warning,
        ^^^^^^^^^^^^^^^^^^^^^^^^^
        stacklevel=2,
        ^^^^^^^^^^^^^
    )
    ^
sphinx.deprecation.RemovedInSphinx10Warning: The tuple interface for _InventoryItem objects is deprecated.

See sphinx-doc/sphinx#13325 for Sphinx release plan.

Expected behavior

No warning.

Steps to reproduce

See https://github.com/mgeier/nbsphinx/actions/runs/13377728736/job/37360423578

@mgeier mgeier added the bug Something isn't working label Feb 17, 2025
@felix-hilden
Copy link
Owner

Thanks! I'll have a look at what we can do 👌

@felix-hilden
Copy link
Owner

It seems that there's some internal work happening to inventories (sphinx-doc/sphinx#13275). Since the type is private and the implementation is "initial", I don't really want to rush changes. Let's see how it develops 👍 Although if you have good ideas on how we can go around this while supporting older Sphinx versions, I'd be interested!

@felix-hilden felix-hilden changed the title Deprecation warning in upcoming Sphinx version InventoryItem deprecation warning since Sphinx 8.2.0 Feb 24, 2025
@mgeier
Copy link
Contributor Author

mgeier commented Mar 2, 2025

I have for now given up supporting Sphinx 8.2 (spatialaudio/nbsphinx#828), so I'm in no hurry!

@AA-Turner
Copy link

AA-Turner commented Mar 2, 2025

It seems that there's some internal work happening to inventories (sphinx-doc/sphinx#13275). Since the type is private and the implementation is "initial"

@felix-hilden the relevant PR is sphinx-doc/sphinx#13248, introducing _InventoryItem. The type is private but the field names are public, so instead of location = info[2] you can use location = info.uri.

However, if you are happy with the deprecation warnings it would be useful for your users to silence them, similarly to how Sphinx silences selected Docutils warnings:

warnings.filterwarnings(
    'ignore',
    'The tuple interface for _InventoryItem objects.*',
    RemovedInSphinx10Warning,
    module='...',
)

@felix-hilden
Copy link
Owner

@mgeier fair enough, good to know!

@AA-Turner Thank you for the guidance! I didn't realise it was meant to be a ready public change already 👌 I think we might ignore the warnings and set an upper bound to Sphinx<10. Then when the time comes to upgrade we can switch the implementation around and support >8.2.

@AA-Turner
Copy link

In general upper bounds are unhelpful for Python packages (Henry Schreiner has articles on this).

Are you able to condition on sphinx.version_info, perhaps via helper functions?

A

@felix-hilden
Copy link
Owner

Fair enough, we could even though testing becomes a bit awkward if we keep going down that road. But with only this it's not so bad 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants