> Before this goes too a big shaky bikeshed over almost nothing, let me > point out that if you're looking to improve something in type > annotations, I would suggest to look for true ugliness there. > Something like Callable[[Dict[str, int], Sequence[Foo]], > Dict[PrimaryKey, List[int]]]. That's rather unreadable.
totally agree on the awkwardness :-) > Actually, let me just quote > https://docs.python.org/3/library/typing.html#typing.Callable > >> Callable type; Callable[[int], str] is a function of (int) -> str. > > Lolwhat? If it's a function of "(int) -> str", then it should be > written just about like that. With > https://www.python.org/dev/peps/pep-0563/ , a lot of things which > weren't previously possible, are now possible. Somebody should start > thinking how to take advantage of that, up to allowing "(int) -> > str”. would be nice too - although this is orthogonal to my initial proposal, right ? > Which is apparently not possible currently, as while "evaluation" is > postponed, it still should parse eagerly as Python syntax. But even > {(int): str} is a better type annotation for a function than > Callable[[int], str]. well, {(int): str} already means something; are you suggesting that an expression like this could have different meanings whether it’s in an annotation or not ? that sounds scary ... > And if we e.g. talk about making "->" a special operator which would > allow it to appear in other contexts than function definition, > "(int) -> str" (and other interesting annotation syntaxes) would be > possible. again, that’s be quite cool for typing function parameters :) _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/XT4VZTLLFUT45DOI5MRZPZAMDPBA6IVJ/ Code of Conduct: http://python.org/psf/codeofconduct/
