Skip to content

docs: fix nitpicky build for TYPE_CHECKING-only annotations - #715

Open
davidpavlovschi wants to merge 1 commit into
pytest-dev:mainfrom
davidpavlovschi:fix/docs-nitpick-type-checking-annotations
Open

docs: fix nitpicky build for TYPE_CHECKING-only annotations#715
davidpavlovschi wants to merge 1 commit into
pytest-dev:mainfrom
davidpavlovschi:fix/docs-nitpick-type-checking-annotations

Conversation

@davidpavlovschi

Copy link
Copy Markdown

Summary

tox -e docs currently fails on main because Sphinx runs in nitpicky mode with warnings treated as errors and cannot resolve four private annotation targets from pluggy._manager.

The annotations now fall back to their source spellings when typing.get_type_hints() encounters names imported only under TYPE_CHECKING. The existing nitpick_ignore entries cover the qualified spellings, but not the emitted _tracing.TagTracerSub, DistFacade, and _Plugin targets.

This adds those three precise targets to nitpick_ignore. It does not broaden the ignore pattern or change runtime code.

Refs #417.

Test plan

  • uv run pytest — 141 passed
  • uv run pre-commit run -a — all 11 hooks passed
  • uv run --with tox tox -e docs — build succeeded (failed before this change)

AI assistance

I used Claude Code with Claude Opus 5 to investigate the regression, prepare the patch, and run an adversarial review. The commit includes the corresponding co-author and session attribution.

`tox -e docs` runs `sphinx-build -W` with `nitpicky = True` and has been
failing since 53eeddf with four unresolved reference targets, all in
`src/pluggy/_manager.py`:

    py:class reference target not found: _tracing.TagTracerSub
    py:class reference target not found: _Plugin
    py:class reference target not found: DistFacade

53eeddf moved `DistFacade` into `_compat` and left both `DistFacade` and
`importlib.metadata` as `TYPE_CHECKING`-only imports. Because `_manager`
uses `from __future__ import annotations`, autodoc's `get_type_hints()`
call now raises `NameError` for `list_plugin_distinfo` and
`list_plugin_distributions`, so it falls back to the annotation text as
written in the source. The emitted cross-reference targets changed from
fully qualified to as-written, and `_Plugin` no longer collapses to
`object` -- so the existing fully qualified `nitpick_ignore` entries stop
matching.

Ignore the as-written spellings alongside the qualified ones. These are
all private names that are intentionally not documented, so nothing that
should resolve is being hidden.

The break went unnoticed because CI does not run the `docs` tox env and
ReadTheDocs builds without `-W`.

Refs pytest-dev#417

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JB8YrcUSkrAojQfiNacSZJ
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.

1 participant