diff --git a/python/stubs/Cython/Build/Inline.pyi b/python/stubs/Cython/Build/Inline.pyi
index ea1e786..7199e42 100644
--- a/python/stubs/Cython/Build/Inline.pyi
+++ b/python/stubs/Cython/Build/Inline.pyi
@@ -1,3 +1,6 @@
 import distutils.command
+from typing import (Any,)
 
 def _get_build_extension() -> distutils.command.build_ext: ...
+
+def load_dynamic(name: str, path: str) -> Any: ...
diff --git a/python/tasks/cython.py b/python/tasks/cython.py
index 47b6211..ac51eb0 100644
--- a/python/tasks/cython.py
+++ b/python/tasks/cython.py
@@ -10,7 +10,7 @@ import threading
 import cython
 import datetime
 
-from typing import (Any, Optional,)
+from typing import (Any, Optional, TypeVar, Type, cast)
 # from scoping import scoping as s
 
 def test(
@@ -31,7 +31,9 @@ def test(
 
     print(['done', started_at, elapsed(), a[_id]])
 
-def build(content: str) -> Any:
+M = TypeVar('M', bound=Type[Any])
+
+def build(content: str, module: M) -> M:
     import pathlib
     import tempfile
     import hashlib
@@ -58,11 +60,14 @@ def build(content: str) -> Any:
         #)
         t1.run()
 
-        return Cython.Build.Inline.load_dynamic(
-            '_%s' % sha256sum,
-            glob.glob(
-                str(output_dir / ('_%s*.so' % sha256sum))
-            )[0]
+        return cast(
+            M,
+            Cython.Build.Inline.load_dynamic(
+                '_%s' % sha256sum,
+                glob.glob(
+                    str(output_dir / ('_%s*.so' % sha256sum))
+                )[0]
+            )
         )
 
     raise NotImplementedError