[issue40494] collections.abc.Callable and type variables

2020-12-25 Thread Guido van Rossum


Guido van Rossum  added the comment:

Indeed. Thanks!

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-12-25 Thread Ken Jin


Ken Jin  added the comment:

Now that issue42195 has been resolved by subclassing types.GenericAlias, can 
this be closed?

On 3.9 and 3.10:

>>> import typing, collections.abc
>>> T = typing.TypeVar('T')
>>> C2 = collections.abc.Callable[[T], T]
>>> C2[int]
collections.abc.Callable[[int], int]

It seems to be fixed :).

--
nosy: +kj

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-11-15 Thread Guido van Rossum


Guido van Rossum  added the comment:

>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.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-05-06 Thread Guido van Rossum


Guido van Rossum  added the comment:

Hm, I am indeed torn. ISTM a subclass just for Callable is slightly better.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-05-04 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Of course. There is more than one way to fix it:

* 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 issue40397).

I think we should first resolve issue40397 and later decide what way be better. 
It is not necessary to reproduce all details of _GenericAlias if the practical 
behavior is the same.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-05-04 Thread Guido van Rossum


Guido van Rossum  added the comment:

Yeah, the fix will require a variant of types.GenericAlias that substitute's 
type variables in lists.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-05-04 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Here I think the behavior of typing.Callable is correct.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue40494] collections.abc.Callable and type variables

2020-05-04 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

There is a difference between typing.Callable and collections.abc.Callable.

>>> import typing, collections.abc
>>> T = typing.TypeVar('T')
>>> C1 = typing.Callable[[T], T]
>>> C2 = collections.abc.Callable[[T], T]
>>> C1
typing.Callable[[~T], ~T]
>>> C2
collections.abc.Callable[[~T], ~T]
>>> C1[int]
typing.Callable[[int], int]
>>> C2[int]
collections.abc.Callable[[~T], int]

--
components: Library (Lib)
messages: 368015
nosy: gvanrossum, levkivskyi, serhiy.storchaka
priority: normal
severity: normal
status: open
title: collections.abc.Callable and type variables
type: behavior
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com