Skip to content

Commit

Permalink
REF: Document Python3.10-specific workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRickli committed Dec 24, 2024
1 parent 407fa08 commit e13b4fa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pdoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,12 @@ def maybe_replace_reprs(a):
try:
a = a.__origin__[args]
except TypeError:
# XXX: Python 3.10-only: Need to convert to list since _CallableGenericAlias.__new__
# currently cannot have tuples as arguments.
args_in = list(args[:-1])
arg_out = args[-1]
# collections.abc.Callable takes "([in], out)"
a = a.__origin__[(list(args[:-1]), args[-1])]
a = a.__origin__[(args_in, arg_out)]
# Recurse into lists
if isinstance(a, (list, tuple)):
return type(a)(map(maybe_replace_reprs, a))
Expand Down

0 comments on commit e13b4fa

Please sign in to comment.