This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2020年04月26日 16:46 by serhiy.storchaka, last changed 2022年04月11日 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 19720 | merged | serhiy.storchaka, 2020年04月26日 19:27 | |
| PR 19857 | merged | serhiy.storchaka, 2020年05月02日 06:45 | |
| Messages (10) | |||
|---|---|---|---|
| msg367313 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2020年04月26日 16:46 | |
>>> from typing import * >>> get_args(Callable) Traceback (most recent call last): File "<stdin>", line 1, in <module> 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? |
|||
| msg367322 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2020年04月26日 17:47 | |
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. |
|||
| msg367327 - (view) | Author: Ivan Levkivskyi (levkivskyi) * (Python committer) | Date: 2020年04月26日 18:38 | |
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. |
|||
| msg367328 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2020年04月26日 18:39 | |
Agreed, that's better! |
|||
| msg367329 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2020年04月26日 18:41 | |
get_args(List) == (T,) |
|||
| msg367331 - (view) | Author: Ivan Levkivskyi (levkivskyi) * (Python committer) | Date: 2020年04月26日 18:56 | |
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. |
|||
| msg367405 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2020年04月27日 07:27 | |
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 |
|||
| msg367898 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2020年05月01日 23:24 | |
@Serhiy is this fixed by PR 19720? |
|||
| msg367919 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2020年05月02日 06:47 | |
Yes, I have not closed this issue yet because it required a manual backporting to 3.8. |
|||
| msg367920 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2020年05月02日 08:08 | |
New changeset a629d4c63c55ba36be36ff105dfc103b710c9a2d by Serhiy Storchaka in branch '3.8': [3.8] bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720) (GH-19857) https://github.com/python/cpython/commit/a629d4c63c55ba36be36ff105dfc103b710c9a2d |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:59:29 | admin | set | github: 84578 |
| 2020年05月02日 08:08:24 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2020年05月02日 08:08:04 | serhiy.storchaka | set | messages: + msg367920 |
| 2020年05月02日 06:47:42 | serhiy.storchaka | set | messages: + msg367919 |
| 2020年05月02日 06:45:55 | serhiy.storchaka | set | pull_requests: + pull_request19173 |
| 2020年05月01日 23:24:47 | gvanrossum | set | messages: + msg367898 |
| 2020年05月01日 22:07:00 | terry.reedy | set | title: get_args(Callable) fails -> typing.get_args(Callable) fails |
| 2020年04月27日 07:27:29 | serhiy.storchaka | set | messages: + msg367405 |
| 2020年04月26日 19:27:10 | serhiy.storchaka | set | keywords:
+ patch stage: patch review pull_requests: + pull_request19042 |
| 2020年04月26日 18:56:43 | levkivskyi | set | messages: + msg367331 |
| 2020年04月26日 18:41:38 | serhiy.storchaka | set | messages: + msg367329 |
| 2020年04月26日 18:39:19 | gvanrossum | set | messages: + msg367328 |
| 2020年04月26日 18:38:25 | levkivskyi | set | messages: + msg367327 |
| 2020年04月26日 17:47:53 | gvanrossum | set | messages: + msg367322 |
| 2020年04月26日 16:46:07 | serhiy.storchaka | create | |