Skip to content

Commit 96221e1

Browse files
authored
BUG: collections.abc.Callable does not allow tuple in Python 3.10 (#454)
* BUG: crash: collections.abc.Callable does not allow tuple in Python 3.10 * REF: Document Python3.10-specific workaround * REF: Make flake8 happy
1 parent 65342ae commit 96221e1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pdoc/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,8 +1354,12 @@ def maybe_replace_reprs(a):
13541354
try:
13551355
a = a.__origin__[args]
13561356
except TypeError:
1357+
# XXX: Python 3.10-only: Convert to list since _CallableGenericAlias.__new__
1358+
# currently cannot have tuples as arguments.
1359+
args_in = list(args[:-1])
1360+
arg_out = args[-1]
13571361
# collections.abc.Callable takes "([in], out)"
1358-
a = a.__origin__[(args[:-1], args[-1])]
1362+
a = a.__origin__[(args_in, arg_out)]
13591363
# Recurse into lists
13601364
if isinstance(a, (list, tuple)):
13611365
return type(a)(map(maybe_replace_reprs, a))

0 commit comments

Comments
 (0)