TLDR: this will allow Modal's func.remote(...) and func.remote.aio(...) to autocomplete the arguments and return types of the underlying function wrapped by @app.function
Details:
A little bit of 🍝 code to get Generic typevars/paramspecs properly forwarded to the inner Protocols used for wrapped async methods, resulting in the type stub for this class:
T = TypeVar("T")
class Foo(Generic[T]):
def method(self, t: T):
...
Resulting in code similar to this:
T = TypeVar("T")
T_INNER = TypeVar("T_INNER")
class Foo(Generic[T]):
class MethodProtocol(typing.Protocol[T_INNER]):
def __call__(self, t: T_INNER):
...
def aio(self, t: T_INNER):
...
method: MethodProtocol[T]
TLDR: this will allow Modal's
func.remote(...)
andfunc.remote.aio(...)
to autocomplete the arguments and return types of the underlying function wrapped by@app.function
Details:
A little bit of 🍝 code to get
Generic
typevars/paramspecs properly forwarded to the inner Protocols used for wrapped async methods, resulting in the type stub for this class:Resulting in code similar to this: