You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2020/09/08 07:52:28 UTC

[incubator-ponymail-foal] branch master updated (b566735 -> 18bad85)

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.


    from b566735  drop a note about runners
     new 90c12e1  Fix type errors found by mypy in endpoints
     new 18bad85  type test endpoints as well

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .travis.yml                     | 1 +
 server/endpoints/oauth.py       | 7 ++++---
 server/endpoints/preferences.py | 4 ++--
 server/endpoints/thread.py      | 4 ++--
 4 files changed, 9 insertions(+), 7 deletions(-)


[incubator-ponymail-foal] 01/02: Fix type errors found by mypy in endpoints

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 90c12e17a6e5f4d63304272fb3d9a3205a216f79
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 09:50:40 2020 +0200

    Fix type errors found by mypy in endpoints
---
 server/endpoints/oauth.py       | 7 ++++---
 server/endpoints/preferences.py | 4 ++--
 server/endpoints/thread.py      | 4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/server/endpoints/oauth.py b/server/endpoints/oauth.py
index 6cf928d..cccc711 100644
--- a/server/endpoints/oauth.py
+++ b/server/endpoints/oauth.py
@@ -37,15 +37,15 @@ async def process(
     id_token = indata.get('id_token')
     oauth_token = indata.get("oauth_token")
 
-    rv = None
+    rv: typing.Optional[dict] = None
 
     # Google OAuth - currently fetches email address only
     if oauth_token and oauth_token.startswith("https://www.googleapis.com/") and id_token:
-        rv: typing.Optional[dict] = await plugins.oauthGoogle.process(indata, session, server)
+        rv = await plugins.oauthGoogle.process(indata, session, server)
 
     # Generic OAuth handler, only one we support for now. Works with ASF OAuth.
     elif state and code and oauth_token:
-        rv: typing.Optional[dict] = await plugins.oauthGeneric.process(indata, session, server)
+        rv = await plugins.oauthGeneric.process(indata, session, server)
 
     if rv:
         # Get UID, fall back to using email address
@@ -78,6 +78,7 @@ async def process(
                 text='{"okay": true}',
             )
 
+    return {"okay": False, "message": "Could not process OAuth login!"}
 
 def register(server: plugins.server.BaseServer):
     return plugins.server.Endpoint(process)
diff --git a/server/endpoints/preferences.py b/server/endpoints/preferences.py
index 7908a22..49dcff6 100644
--- a/server/endpoints/preferences.py
+++ b/server/endpoints/preferences.py
@@ -26,8 +26,8 @@ import plugins.session
 async def process(
     server: plugins.server.BaseServer, session: plugins.session.SessionObject, indata: dict
 ) -> dict:
-    prefs = {"login": {}}
-    lists = {}
+    prefs: dict = {"login": {}}
+    lists: dict = {}
     for ml, entry in server.data.lists.items():
         if "@" in ml:
             lname, ldomain = ml.split("@", 1)
diff --git a/server/endpoints/thread.py b/server/endpoints/thread.py
index 7876857..779dbe2 100644
--- a/server/endpoints/thread.py
+++ b/server/endpoints/thread.py
@@ -21,13 +21,13 @@ import plugins.server
 import plugins.session
 import plugins.mbox
 import plugins.defuzzer
-
+import typing
 
 async def process(
     server: plugins.server.BaseServer,
     session: plugins.session.SessionObject,
     indata: dict,
-) -> dict:
+) -> typing.Optional[dict]:
     email = await plugins.mbox.get_email(session, permalink=indata.get("id"))
     if not email:
         email = await plugins.mbox.get_email(session, messageid=indata.get("id"))


[incubator-ponymail-foal] 02/02: type test endpoints as well

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 18bad853a5e52fc8b30eb77d6683558da51e58fa
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 8 09:51:07 2020 +0200

    type test endpoints as well
---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index c92960a..4ea1802 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,6 +27,7 @@ script:
   - mypy --ignore-missing-imports tools/import-mbox.py
   - mypy --ignore-missing-imports server/main.py
   - mypy --ignore-missing-imports server/plugins/*.py
+  - mypy --ignore-missing-imports server/endpoints/*.py
 
 jobs:
   include: