Am 10.06.21 um 02:25 schrieb Steven Troxler:
## Alternatives considered
We ran a poll at the typing summit comparing three options for nicer Callable syntax:
* This proposal `(ArgType1, ArgType2, ArgType3) -> ReturnType` * 72% of participants upvoted this * A typescript-like syntax `(a: ArgType1, b: ArgType2) => ReturnType` * 62% of participants upvoted this * Disadvantages are * a new symbol `=>` * argument names are nuisance parameters for positional args (which is all the existing Callable supports) * `[ArgType1, ArgType2, ArgType3] -> ReturnType` * 8% of participants upvoted this * The main disadvantage is that brackets don’t seem as intuitive
I think option 1 is the best. This could later be extended to also allow "(a: ArgType) -> None" or "(ArgType = ...)", but for now having syntactic sugar for Callable would be nice. One thing I miss is an alternative for "Callable[..., None]", though. This is be part of this PEP, to be able to fully replace Callable. Options I can see are "(...) -> None" or "... -> None". I think the main obstacle with this PEP is that this is the first time that we allow special syntax inside type annotations. This will be a hard sell. Finally, a bit off-topic for this proposal, but related: Łukasz suggested to be able to use ordinary "def"s for more complicated definitions: def Foo(x: int, *, y: str = ...) -> Any: ... def bar(cb: Foo) -> None: cb(123, y="abc") This could be an easy replacement for callable protocols. - Sebastian