Browse Source

Add some more static types

Getty Ritter 4 years ago
parent
commit
5bcbbc0a24
3 changed files with 12 additions and 4 deletions
  1. 2 2
      lc/web.py
  2. 6 0
      stubs/pystache/__init__.py
  3. 4 2
      stubs/pystache/loader.py

+ 2 - 2
lc/web.py

@@ -109,7 +109,7 @@ def endpoint(route: str):
     # called with the result of the definition after it. The argument
     # to what we're calling `do_endpoint` here is going to be the
     # class object defined afterwards.
-    def do_endpoint(endpoint_class):
+    def do_endpoint(endpoint_class: Type[Endpoint]):
         # we'll just make that explicit here
         assert Endpoint in endpoint_class.__bases__
         # finally, we need a function that we'll give to Flask in
@@ -137,7 +137,7 @@ def endpoint(route: str):
 LOADER = pystache.loader.Loader(extension="mustache", search_dirs=["templates"])
 
 
-def render(name, **kwargs):
+def render(name: str, **kwargs) -> str:
     """Load and use a Mustache template from the project root"""
     template = LOADER.load_name(name)
     renderer = pystache.Renderer(missing_tags="strict", search_dirs=["templates"])

+ 6 - 0
stubs/pystache/__init__.py

@@ -1 +1,7 @@
+from typing import Any, List
+
 import pystache.loader
+
+class Renderer:
+    def __init__(self, missing_tags: str, search_dirs: List[str]): pass
+    def render(self, template: Any, kwargs: dict): pass

+ 4 - 2
stubs/pystache/loader.py

@@ -1,6 +1,8 @@
-from typing import List
-
+from typing import Any, List
 
 class Loader:
     def __init__(self, extension: str, search_dirs: List[str]):
         pass
+
+    def load_name(self, name: str) -> Any:
+        pass