You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using these could permit us to add type-checking to Function interfaces whose callables have type/trait annotations for their arguments and return values, and drastically reduce boilerplate for simple interfaces.
The goal wouldn't be to replace the current approach for defining interfaces (although perhaps we could make spec-writing much simpler using similar approaches), and promiscuously typed Function interfaces should still be doable, but this could narrow the gap between full interfaces and Function interfaces substantially.
just a note that full support i believe is only Py 3.6+, but i'm all for reducing boilerplate. we can even introduce an interface decorator that one simply has to attach to the function.
Python 3 has added annotations, which are accessible via the
inspect.getfullargspec
function or theinspect.Signature
API.Using these could permit us to add type-checking to
Function
interfaces whose callables have type/trait annotations for their arguments and return values, and drastically reduce boilerplate for simple interfaces.For example, suppose we want to have a function:
This would be equivalent to the current approach:
For more complicated options, annotations could be fully-fledged traits:
The goal wouldn't be to replace the current approach for defining interfaces (although perhaps we could make spec-writing much simpler using similar approaches), and promiscuously typed
Function
interfaces should still be doable, but this could narrow the gap between full interfaces andFunction
interfaces substantially.Conversation started in #2520.
Related: #2081 #2083 #2220
The text was updated successfully, but these errors were encountered: