pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Forward references break with NamedTuples

Open khusmann opened this issue 1 year ago • 0 comments

Problem Description

Thanks for this library! Hopefully this is an easy one: Forward references inside NamedTuples do not get resolved and result in a warning

Steps to reproduce the behavior:

from __future__ import annotations
from typing import NamedTuple

class Foo(NamedTuple):
    b: Bar

class Bar:
    pass

Results in:

Warn: Error parsing type annotation ForwardRef('Bar') for bug.Foo.__init__. Import of Bar failed: name 'Bar' is not defined

It appears to just be NamedTuples -- regular classes (and dataclasses) do not produce this warning.

System Information

pdoc: 15.0.1
Python: 3.10.8
Platform: Linux-5.15.0-125-generic-x86_64-with-glibc2.31

khusmann avatar Dec 22 '24 20:12 khusmann