GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — bug: relative cross-references in inherited members are expanded against the inheriting class · Issue #341 · mkdocstrings/python Closed DescriptionDescription of the bugWhen a class inherits from a class defined in another package and The expansion happens in That has two visible consequences. The expanded identifier points at the wrong place. In the reproducer, The expansion is also gated on the consumer's own which is fatal under Incidentally, To Reproducemkdir -p repro/pkga repro/pkgb repro/docs-a repro/docs-b cd repro python -m venv .venv . .venv/bin/activate pip install -q mkdocs 'mkdocstrings[python]' cat > pkga/__init__.py <<'EOF' """Package A (the dependency).""" from pkga._core import Thing __all__ = ["Thing"] EOF cat > pkga/_core.py <<'EOF' """Core objects of package A.""" class Thing: """A thing, defined by package A.""" EOF cat > pkga/sub.py <<'EOF' """Sub-module of package A.""" from typing import Any class Base: """A base class.""" MAPPING: dict[str, Any] = {} """The mapping to use for each [`Thing`][....Thing].""" EOF cat > pkgb/__init__.py <<'EOF' """Package B (the downstream consumer).""" from pkga.sub import Base class Thing: """A completely unrelated thing, which happens to have the same name.""" class Derived(Base): """A class derived from package A's base class.""" EOF echo '# Package A ::: pkga ::: pkga.sub' > docs-a/index.md echo '# Package B ::: pkgb' > docs-b/index.md cat > mkdocs-a.yml <<'EOF' site_name: pkga docs_dir: docs-a site_dir: site-a strict: true plugins: - mkdocstrings: handlers: python: options: relative_crossrefs: true EOF cat > mkdocs-b.yml <<'EOF' site_name: pkgb docs_dir: docs-b site_dir: site-b strict: true plugins: - mkdocstrings: handlers: python: options: preload_modules: [pkga] inherited_members: true # relative_crossrefs is deliberately NOT enabled here EOF echo "### 1. pkga's own docs (relative_crossrefs enabled): reference is correct" mkdocs build -f mkdocs-a.yml 2>&1 | tail -3 grep -o 'The mapping to use for each <a[^>]*>' site-a/index.html | tail -1 echo echo "### 2. pkgb's docs, without relative_crossrefs: the raw dotted string leaks" mkdocs build -f mkdocs-b.yml 2>&1 | tail -3 || true grep -o 'The mapping to use for each .*\.$' site-b/index.html | tail -1 || true echo echo "### 3. pkgb's docs, with relative_crossrefs: expanded against the WRONG class" sed -i 's/ # relative_crossrefs.*/ relative_crossrefs: true/' mkdocs-b.yml mkdocs build -f mkdocs-b.yml 2>&1 | tail -3 grep -o 'The mapping to use for each <a[^>]*>' site-b/index.html | tail -1 Output: In the repro Full tracebackThere is no traceback. The failure surfaces as the Environment informationpython -m mkdocstrings_handlers.python._internal.debug - __System__: Linux-6.12.107+deb13-amd64-x86_64-with-glibc2.42 - __Python__: cpython 3.12.14 - __Environment variables__: - __Installed packages__: - `mkdocs` v1.6.1 - `mkdocstrings` v1.0.6 - `mkdocstrings-python` v2.0.8 - `mkdocs-autorefs` v1.4.4 - `griffelib` v2.3.0 Additional contextReal-world occurrence: frequenz-quantities documents On a possible direction: expanding against Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |