Skip to content

References to pathlib objects are incorrectly picked up by autodoc #13178

Closed
@cjw296

Description

@cjw296

Describe the bug

Type annotations using pathlib.Path of callable that are handed by autodoc generate the following warning on Python 3.13:

{filename}.py:docstring of {callable}:1: WARNING: py:class reference target not found: pathlib._local.Path [ref.class]

They do not on 3.12 and below.

How to Reproduce

Failing build on RTD: https://readthedocs.org/projects/sybil/builds/26566926/
Passing build on RTD: https://readthedocs.org/projects/sybil/builds/26567027/

Only difference is Python 3.12 versus 3.13.

Python source being auto-doc'ed:

https://github.com/simplistix/sybil/blob/8d58cfe196a9f8136f8eea453805e6e3c9e6b263/sybil/sybil.py#L159-L164

Sphinx .rst referencing this:

https://github.com/simplistix/sybil/blob/8d58cfe196a9f8136f8eea453805e6e3c9e6b263/docs/api.rst?plain=1#L14-L16

Sphinx config:

https://github.com/simplistix/sybil/blob/8d58cfe196a9f8136f8eea453805e6e3c9e6b263/docs/conf.py#L1-L45

Environment Information

$ python -m sphinx --bug-report
Please paste all output below into the bug report template


...gave:

```text
Platform:              darwin; (macOS-15.1.1-arm64-arm-64bit-Mach-O)
Python version:        3.13.0 (main, Oct  7 2024, 23:47:22) [Clang 18.1.8 ])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

"sphinx.ext.autodoc" is the one here.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions