-
-
Notifications
You must be signed in to change notification settings - Fork 200
Open
Labels
Description
Problem Description
Using a type defined using a type alias produces a warning message and uses ForwardRef('TheType')
in documentation output instead of the correct TheType
.
Sample code:
from __future__ import annotations
from typing import NamedTuple
import numpy
from numpy.typing import NDArray
type Array = NDArray[numpy.float64]
class ArrayThing(NamedTuple):
data: Array
This triggers the following warning when running pdoc:
$ PDOC_ALLOW_EXEC=1 uv run --quiet --locked pdoc -d google -o docs --math foo
Warn: Error parsing type annotation ForwardRef('Array') for foo.foo.ArrayThing.__init__. Import of Array failed: name 'Array' is not defined (/home/me/pdoc_test/.venv/lib/python3.13/site-packages/pdoc/doc_types.py:148)
The output is usable but slightly verbose (it includes the ForwardRef
instead of directly naming the type which has been defined:

Steps to reproduce the behavior:
- Run pdoc on the python source defined above!
System Information
$ PDOC_ALLOW_EXEC=1 uv run --quiet --locked pdoc -d google -o docs --math --version
pdoc: 15.0.4
Python: 3.13.1
Platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.36