You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
collections.abc.Callable and type variables #84674
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2020-12-25.22:10:21.763>created_at=<Date2020-05-04.08:07:12.472>labels= ['type-bug', 'library', '3.9']
title='collections.abc.Callable and type variables'updated_at=<Date2020-12-25.22:10:21.762>user='https://github.com/serhiy-storchaka'
Make GenericAlias substituting type variables in list. It is easier and it will fix this particular case, but there will be subtle differences in __args__.
Add a GenericAlias subclass with overridden constructor, __repr__, __getitem__, __reduce__ (like the _GenericAlias subclass added in bpo-40397).
I think we should first resolve bpo-40397 and later decide what way be better. It is not necessary to reproduce all details of _GenericAlias if the practical behavior is the same.
Activity
serhiy-storchaka commentedon May 4, 2020
There is a difference between typing.Callable and collections.abc.Callable.
ilevkivskyi commentedon May 4, 2020
Here I think the behavior of typing.Callable is correct.
gvanrossum commentedon May 4, 2020
Yeah, the fix will require a variant of types.GenericAlias that substitute's type variables in lists.
serhiy-storchaka commentedon May 4, 2020
Of course. There is more than one way to fix it:
I think we should first resolve bpo-40397 and later decide what way be better. It is not necessary to reproduce all details of _GenericAlias if the practical behavior is the same.
gvanrossum commentedon May 6, 2020
Hm, I am indeed torn. ISTM a subclass just for Callable is slightly better.
gvanrossum commentedon Nov 16, 2020
From https://bugs.python.org/issue42195 it looks like we need to create a subclass just for Callable. See https://bugs.python.org/issue42102 and PR 22848.
Fidget-Spinner commentedon Dec 25, 2020
Now that bpo-42195 has been resolved by subclassing types.GenericAlias, can this be closed?
On 3.9 and 3.10:
It seems to be fixed :).
gvanrossum commentedon Dec 25, 2020
Indeed. Thanks!