/Users/.../test/docs/autoapi/test/index.rst:38: WARNING: py:class reference target not found: Path
I have found that this issue is due to using Path | None in a type annotation. This issue goes away if I use one pathlib.Path | None, Optional[Path], or Union[Path, None].
To reproduce:
Python 3.10.5
Sphinx 6.1.3
sphinx-autoapi 2.0.1
% tree
.
├── docs
│ ├── Makefile
│ ├── conf.py
│ └── index.rst
└── src
└── test
└── __init__.py
# __init__.py
import pathlib
from pathlib import Path
from typing import Optional, Union
def simple(self, p: Path):
"""This is OK"""
def optional(self, p: Optional[Path]):
"""This is OK"""
def union(self, p: Union[Path, None]):
"""This is OK"""
def pipe(self, p: Path | None):
"""This fails autoapi unless use ``pathlib.Path | None`` instead"""
I have made an MRE for an error I am getting:
I have found that this issue is due to using
Path | None
in a type annotation. This issue goes away if I use onepathlib.Path | None
,Optional[Path]
, orUnion[Path, None]
.To reproduce: