Special case: Callable
with one argument?
#1344
eliegoudout
started this conversation in
General
Replies: 1 comment 1 reply
-
I believe runtime support for this syntax is accidental. The implementation of Callable is highly complex (in order to support ParamSpec, substitution, etc.). I don't think type checkers should support this syntax. It's better that there's only one syntax so the overall language feels more consistent. In other cases where the first type argument to Callable doesn't require brackets ( |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I noticed that in the case of a
Callable
with only one argument, my Python interpreter handles the following wrong syntax perfectly:which I find great for readability.
Is this a documented behaviour? Because for example,
Mypy
doesn't accept this syntax, as per its specification. I went through several PEPs mentionningCallable
and I couldn't find any reference to this. I could only find following usages:If it is in fact not documented yet, is it planned to be? Maybe it cannot because of conflicts of some type with
ParamSpec
? I'm not at all an expert at typing so I wouldn't know.Thanks for enlightening me :)
Beta Was this translation helpful? Give feedback.
All reactions