typing.get_args(Callable) fails #84578
Copy link
Copy link
Closed
Labels
3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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 = None
closed_at = <Date 2020-05-02.08:08:24.496>
created_at = <Date 2020-04-26.16:46:07.424>
labels = ['3.8', 'type-bug', 'library', '3.9']
title = 'typing.get_args(Callable) fails'
updated_at = <Date 2020-05-02.08:08:24.495>
user = 'https://github.com/serhiy-storchaka'bugs.python.org fields:
activity = <Date 2020-05-02.08:08:24.495>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2020-05-02.08:08:24.496>
closer = 'serhiy.storchaka'
components = ['Library (Lib)']
creation = <Date 2020-04-26.16:46:07.424>
creator = 'serhiy.storchaka'
dependencies = []
files = []
hgrepos = []
issue_num = 40398
keywords = ['patch']
message_count = 10.0
messages = ['367313', '367322', '367327', '367328', '367329', '367331', '367405', '367898', '367919', '367920']
nosy_count = 3.0
nosy_names = ['gvanrossum', 'serhiy.storchaka', 'levkivskyi']
pr_nums = ['19720', '19857']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue40398'
versions = ['Python 3.8', 'Python 3.9']Metadata
Metadata
Assignees
Labels
3.8 (EOL)end of lifeend of life3.9 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
serhiy-storchaka commentedon Apr 26, 2020
What is the correct behavior?
gvanrossum commentedon Apr 26, 2020
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.
ilevkivskyi commentedon Apr 26, 2020
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.
gvanrossum commentedon Apr 26, 2020
Agreed, that's better!
serhiy-storchaka commentedon Apr 26, 2020
get_args(List) == (T,)
ilevkivskyi commentedon Apr 26, 2020
Oh my, this looks like another bug. I don't have Python 3.8 at hand so just tried
typing_inspecton Python 3.6. I think this may be caused by the "double use" of _GenericAlias for which you opened your WIP PR.serhiy-storchaka commentedon Apr 27, 2020
New changeset 6292be7 by Serhiy Storchaka in branch 'master':
bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)
6292be7
[-]get_args(Callable) fails[/-][+]typing.get_args(Callable) fails[/+][-]get_args(Callable) fails[/-][+]typing.get_args(Callable) fails[/+]gvanrossum commentedon May 1, 2020
@serhiy is this fixed by PR 19720?
serhiy-storchaka commentedon May 2, 2020
Yes, I have not closed this issue yet because it required a manual backporting to 3.8.
serhiy-storchaka commentedon May 2, 2020
New changeset a629d4c by Serhiy Storchaka in branch '3.8':
[3.8] bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720) (GH-19857)
a629d4c