[issue40398] get_args(Callable) fails

2020-04-27 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 6292be7adf247589bbf03524f8883cb4cb61f3e9 by Serhiy Storchaka in 
branch 'master':
bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)
https://github.com/python/cpython/commit/6292be7adf247589bbf03524f8883cb4cb61f3e9


--

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +19042
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19720

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Oh my, this looks like another bug. I don't have Python 3.8 at hand so just 
tried `typing_inspect` on Python 3.6. I think this may be caused by the "double 
use" of _GenericAlias for which you opened your WIP PR.

--

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

get_args(List) == (T,)

--

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Guido van Rossum


Guido van Rossum  added the comment:

Agreed, that's better!

--

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

I think it should return empty tuple: First, for consistency with other things 
like get_args(Tuple) == () and get_args(List) == (). Second, although Callable 
is equivalent to Callable[..., Any] in the static world, authors of some 
runtime checkers might want to distinguish whether a user wrote one or another.

--

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Guido van Rossum


Guido van Rossum  added the comment:

Maybe it could return (Ellipsis, Any) in that case. The most general form of 
Callable is Callable[..., Any] and that's that get_args() returns for that.

--

___
Python tracker 

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



[issue40398] get_args(Callable) fails

2020-04-26 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

>>> from typing import *
>>> get_args(Callable)
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/typing.py", line 1412, in get_args
if get_origin(tp) is collections.abc.Callable and res[0] is not Ellipsis:
IndexError: tuple index out of range

What is the correct behavior?

--
components: Library (Lib)
messages: 367313
nosy: gvanrossum, levkivskyi, serhiy.storchaka
priority: normal
severity: normal
status: open
title: get_args(Callable) fails
type: behavior
versions: Python 3.8, Python 3.9

___
Python tracker 

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