◐ Shell
clean mode source ↗

gh-91621: Fix typing.get_type_hints for collections.abc.Callable by hauntsaninja · Pull Request #91656 · python/cpython

Fidget-Spinner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

for arg in t.__args__
)
t = t.__origin__[args]
if (t.__origin__ is collections.abc.Callable

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this code pattern appears once in Generic code and once here now. Should we just convert this into one function? Maybe _should_flatten_callable_args()? Seems abit tiresome to repeat this (and it's also confusing for people who haven't dealt with Callable's args before).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sorry, missed this comment)
I added a helper function for this