Skip to content

Keep builtin annotations from resolving to project attributes in Sphinx 9 - #74168

Merged
shahar1 merged 2 commits into
apache:mainfrom
shahar1:docs-sphinx9-builtin-xrefs
Oct 3, 2026
Merged

shahar1 merged 2 commits into
apache:mainfrom
shahar1:docs-sphinx9-builtin-xrefs

Conversation

@shahar1

@shahar1 shahar1 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

related: #74151
related: #74167

AI Summary

The docs build runs on the default Python, and uv.lock resolves Sphinx 8.1.3 on Python 3.10 but Sphinx 9.0.4 on 3.11 (9.1.0 on 3.12+). Moving the default to 3.11 (#74151) therefore moves the docs build to Sphinx 9, and the docs and spellcheck jobs fail.

Part of that failure is an upstream regression, sphinx-doc/sphinx#14223: Sphinx 9 added a fallback from a py:class lookup to a fuzzy py:data/py:attr search when resolving annotation cross-references. A builtin such as type or object in an annotation then matches every documented attribute with that name:

WARNING: more than one target found for cross-reference 'type': airflow.providers.openlineage.plugins.facets.UnknownOperatorInstance.type, airflow.providers.openlineage.utils.utils.AssetInfo.type
WARNING: more than one target found for cross-reference 'object': airflow.providers.google.cloud.sensors.gcs.GCSObjectExistenceSensor.object, airflow.providers.google.cloud.sensors.gcs.GCSObjectUpdateSensor.object

The new python_builtin_xrefs extension overrides the Python domain's resolve_xref so that a builtin name with no exact match is left unresolved instead of going through that fallback. Intersphinx then links it to the Python docs, which is what Sphinx 8 did. Non-builtin names are untouched. A plain suppress_warnings = ["ref.python"] would hide the warning but leave type/object linking to an unrelated attribute.

The extension is registered in BASIC_SPHINX_EXTENSIONS (used by the core, provider, chart, ctl and docker-stack docs). Removal is tracked in #74167.

The remaining Sphinx 9 warnings are genuine docstring mistakes and are fixed separately in #74169.

Checks run: the new test passes on Sphinx 9.0.4 (Python 3.11) and 8.1.3 (Python 3.10) and fails on 9.0.4 without the extension; mypy-devel-common passes; with both PRs applied, --docs-only for amazon, google, openlineage and task-sdk passes on Python 3.11 / Sphinx 9.0.4, and google spellcheck passes.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5.5)

Generated-by: Claude Code (Opus 5.5) following the guidelines

🤖 Generated with Claude Code

https://claude.ai/code/session_01SkLWWaTT1cnFqTT1jhFGxe

…nx 9

Sphinx 9 falls back from a class lookup to a fuzzy data/attribute search
when resolving annotation cross-references. A builtin such as type or
object in an annotation then matches every documented attribute with
that name, and the docs build fails with "more than one target found"
(sphinx-doc/sphinx#14223). Python 3.11 and newer resolve Sphinx 9 from
the lock file, so the docs build breaks as soon as it moves off 3.10.
Skipping that fallback for builtin names restores the Sphinx 8 behaviour
of linking them to the Python documentation.

Claude-Session: https://claude.ai/code/session_01SkLWWaTT1cnFqTT1jhFGxe
The docs build still type-checks against Sphinx 8 on Python 3.10, where
PythonDomain.resolve_xref returns Element | None, while Sphinx 9 narrows
it to reference | None. No single precise annotation is a valid override
for both.

Claude-Session: https://claude.ai/code/session_01SkLWWaTT1cnFqTT1jhFGxe
@shahar1
shahar1 requested review from dabla, eladkal and potiuk October 3, 2026 17:22
@shahar1
shahar1 merged commit 4a73cb7 into apache:main Oct 3, 2026
79 checks passed
@shahar1
shahar1 deleted the docs-sphinx9-builtin-xrefs branch October 3, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants