Yes, and yes. (Or the PEP could say it has to be ‘…’ and static checkers could enforce it. But checkers already carry everything they need to check this with them, for checking calls.)
Downside of this idea is that it requires you to invent a name for every callable type you use. On Thu, Dec 23, 2021 at 17:37 Barry Warsaw <[email protected]> wrote: > On Dec 23, 2021, at 17:09, Guido van Rossum <[email protected]> wrote: > > > > Mark's proposal was > > ``` > > @Callable > > def func(params): pass > > ``` > > My question is, why does it need `@Callable`? Lukasz proposed just using > any (undecorated) function, with the convention being that the body is > `...` (to which I would add the convention that the function *name* be > capitalized, since it is a type). My question (for Mark, or for anyone who > supports `@Callable`) is why bother with the decorator. It should be easy > to teach a type checker about this: > > > > ``` > > def SomeFn(x: float) -> int: > > ... > > > > def twice(f: SomeFn) -> SomeFn: > > return lambda x: f(f(x)) > > ``` > > That seems pretty intuitive to me. The conventions you mention would be > just that though, right? I.e. `pass` could be used, but whatever the body > is it would be ignored for type checking `twice()` in this case, right? > > -Barry > > > _______________________________________________ > Python-Dev mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/BRYQ26TIYPITNDOYYYGBDFS5EYEOZVUA/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- --Guido (mobile)
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/WW6QAPAZ2RTCWSSK2XJIJP3VWVHCOL7Q/ Code of Conduct: http://python.org/psf/codeofconduct/
