Eric Traut wrote:
I like the idea of a less-cumbersome way to annotate callables. Did you consider using parentheses (i.e. tuple notation) rather than square brackets? Parentheses would more closely mirror the punctuation of a function declaration, so it might be more natural to most Python developers. (ParamType1, ParamType2, ParamType3) -> ReturnType
I am very encouraged by the trend set in motion by PEP 604 of simpler annotation syntax; the benefit of having readers intuit an an annotation at a glance is enormous. This proposal feels like another step in that direction. Two others that crop up a lot are Sequence (for lists + tuples + ...) and Iterable, but I guess we are running out of syntax—with `{ ... }` , and maybe `[ ... ]`, as a few of the "containers" left. Here's an example Dave Beazley posted to Twitter: ``` def read_csv_as_dicts( lines: Iterable[str], *, types: Sequence[Callable[[str],Any]]=None, headers: Sequence[str]=None ) -> List[Dict[str,Any]]: ``` Imagining `[ ]` for sequences, `iter` for Iterable, and the above function syntax, that could become: ``` def read_csv_as_dicts( lines: iter(str), *, types: [(str) -> Any, ...]=None, headers: [str, ...]=None ) -> list[dict[str, Any]]: ``` which to my eye, ignoring the feasibility of the exact form, becomes eminently more readable and helpful. Thanks to everyone who is working hard to think through and sort out this syntax. Stéfan