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 <[email protected]> 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"))
