Open warner-benjamin opened 1 year ago
Here's a minimal repro:
from fastcore.basics import eval_type
eval_type('list[float|int]', {}, {})
The issue is that fastcore's backport of py310-style annotations (e.g. float|int
) doesn't support generic types, see this line: https://github.com/fastai/fastcore/blob/86337bad16a65f23c5335286ab73cd4d6425c586/fastcore/basics.py#L304
I wonder if we should be evaluating types for show_doc
at all? If we don't, we would avoid https://github.com/fastai/nbdev/issues/1116 too. cc @jph00
It would be worth trying removing eval and seeing how that changes, for instance, the fastai and nbdev docs
show_doc
errors out when using Python 3.10 union sub-type hints. This occurs with typing.ListList[Tensor|int]
or listlist[Tensor|int]
Minimal reproducible code and error:
Error:
However, using optional
list[Optional[float]]
or unionUnion
list[Union[float, int]]
works.Using user-defined generic types renders the table, but displays
list[T]
as the type, notlist[int, float]
(or something similar).