Skip to content

Commit

Permalink
BUG: collections.abc.Callable does not allow tuple in Python 3.10 (#454)
Browse files Browse the repository at this point in the history
* BUG: crash: collections.abc.Callable does not allow tuple in Python 3.10

* REF: Document Python3.10-specific workaround

* REF: Make flake8 happy
  • Loading branch information
StefanRickli authored Dec 29, 2024
1 parent 65342ae commit 96221e1
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: 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__[(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 96221e1

Please sign in to comment.