Skip to content

bug: Inventory config 'base_url' no longer works #268

Closed

Description

@connesy

Description of the bug

When specifying an inventory with a base_url that is different from the url, the base_url is ignored after the 0.28.0 rework. The rendered cross-reference URL uses the url value, not the base_url value.

The issue is that the new Inventory dataclass in https://github.com/mkdocstrings/python/blob/main/src/mkdocstrings_handlers/python/_internal/config.py#L963-L992 has a base attribute, which is also returned in the _config property as base, and not base_url. However, the load_inventory method still expects a base_url keyword, but now gets base=... which is put into **kwargs and ignored.

Environment information

python -m mkdocstrings_handlers.python._internal.debug  # | xclip -selection clipboard
  • System: Linux-6.11.0-21-generic-x86_64-with-glibc2.39
  • Python: cpython 3.12.3 (/home/stefan/salling/ml-utils-pipeline-new/.venv/bin/python)
  • Environment variables:
  • Installed packages:
    • mkdocstrings-python v1.16.8

Additional context

I'll be happy to make a PR fixing this, but I could use some help in figuring out how to add test(s) 🙂

Activity

  1. added
    unconfirmed
    on Apr 3, 2025
  2. pawamoy commented on Apr 3, 2025

    @pawamoy
    Member

    Good catch @connesy, thanks for the report!

    A PR would be great, thank you 🙏 I believe we just need to rename base to base_url then, in the Inventory dataclass, do you agree?

    For tests, we could add them to the test_handler.py module. They would receive the handler fixture, onto which we would update config.inventories to add an Inventory with both URL and base URL (might need to dataclasses.replace() it if fields are frozen). Then we would create a BytesIO that mocks the bytes of a small inventory (one item), get the URL and config with url, config = handler.get_inventory_urls(), and call handler.load_inventory(mocked_bytes, url, **config), finally asserting that this yields an URL based on the provided base URL.

    To mock the inventory bytes, we can create a mkdocstrings.Inventory, .register() one item, and get the bytes with .format_sphinx().

  3. added
    bug
    and removed
    unconfirmed
    on Apr 3, 2025
  4. connesy commented on Apr 3, 2025

    @connesy
    ContributorAuthor

    I believe we just need to rename base to base_url then, in the Inventory dataclass, do you agree?

    Yes, I do. I've already tested this, and it works just fine 👍

    I'll make a PR and try adding a test case 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions