Browse Source

Automatic formatting commit: 2020-04-17T17:31:20.414996

Getty Ritter 4 years ago
parent
commit
97012354b2
6 changed files with 15 additions and 7 deletions
  1. 4 2
      lc/model.py
  2. 1 0
      lc/view.py
  3. 3 3
      lc/web.py
  4. 3 0
      stubs/pytest.py
  5. 3 1
      tasks.py
  6. 1 1
      tests/model.py

+ 4 - 2
lc/model.py

@@ -72,7 +72,7 @@ class User(Model):
         return f"/u/{self.name}"
 
     def get_links(
-        self, as_user: Optional['User'], page: int
+        self, as_user: Optional["User"], page: int
     ) -> Tuple[List[v.Link], v.Pagination]:
         links = (
             Link.select()
@@ -203,7 +203,9 @@ class Tag(Model):
     def url(self) -> str:
         return f"/u/{self.user.name}/t/{self.name}"
 
-    def get_links(self, as_user: Optional[User], page: int) -> Tuple[List[Link], v.Pagination]:
+    def get_links(
+        self, as_user: Optional[User], page: int
+    ) -> Tuple[List[Link], v.Pagination]:
         links = [
             ht.link.to_view(as_user)
             for ht in HasTag.select()

+ 1 - 0
lc/view.py

@@ -35,6 +35,7 @@ class UserInvite(View):
     claimant: str
     token: str
 
+
 @dataclass
 class AdminPane(View):
     invites: List[UserInvite]

+ 3 - 3
lc/web.py

@@ -91,11 +91,11 @@ class Endpoint:
                 # should redirect to the page where that information
                 # can be viewed instead of returning that
                 # information. (I think.)
-                api_ok = self.api_post(*args, **kwargs) # type: ignore
+                api_ok = self.api_post(*args, **kwargs)  # type: ignore
                 assert isinstance(api_ok, ApiOK)
                 return flask.jsonify(api_ok.response)
             elif flask.request.method == "DELETE":
-                return flask.jsonify(self.api_delete(*args, **kwargs).response) # type: ignore
+                return flask.jsonify(self.api_delete(*args, **kwargs).response)  # type: ignore
             elif (
                 flask.request.method in ["GET", "HEAD"]
                 and flask.request.content_type == "application/json"
@@ -106,7 +106,7 @@ class Endpoint:
                 # I like using the HTTP headers to distinguish these
                 # cases, while other APIs tend to have a separate /api
                 # endpoint to do this.
-                return flask.jsonify(self.api_get(*args, **kwargs).response) # type: ignore
+                return flask.jsonify(self.api_get(*args, **kwargs).response)  # type: ignore
         # if an exception arose from an "API method", then we should
         # report it as JSON
         except e.LCException as exn:

+ 3 - 0
stubs/pytest.py

@@ -1,10 +1,13 @@
 from typing import Type
 
+
 class RaisesContext:
     def __enter__(self):
         pass
+
     def __exit__(self, _1, _2, _3):
         pass
 
+
 def raises(e: Type[Exception]) -> RaisesContext:
     pass

+ 3 - 1
tasks.py

@@ -54,7 +54,9 @@ def populate(c):
 @task
 def tc(c):
     """Typecheck with mypy"""
-    c.run("MYPYPATH=$(pwd)/stubs poetry run mypy --check-untyped-defs lc/*.py tests/*.py scripts/*.py")
+    c.run(
+        "MYPYPATH=$(pwd)/stubs poetry run mypy --check-untyped-defs lc/*.py tests/*.py scripts/*.py"
+    )
 
 
 @task

+ 1 - 1
tests/model.py

@@ -144,7 +144,7 @@ class Testdb:
         req = r.Link("http://foo.com", "foo", "", False, ["foo", "bar"])
         l = m.Link.from_request(u, req)
         assert l.name == req.name
-        assert l.tags == ["foo", "bar"] # type: ignore
+        assert l.tags == ["foo", "bar"]  # type: ignore
 
         # check the in-place update
         req.name = "bar"