From 6775e09c7a4854f1915928a6c38082f511330e50 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 12 Sep 2022 18:26:09 +0000 Subject: [PATCH] More typing --- divent/bot.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/divent/bot.py b/divent/bot.py index 26484f6..054d9a8 100644 --- a/divent/bot.py +++ b/divent/bot.py @@ -3,7 +3,7 @@ import logging from datetime import datetime, timedelta from functools import wraps from os import environ, path -from typing import Optional +from typing import Dict, List, Optional from disnake import Client, Guild from dotenv import load_dotenv @@ -78,7 +78,9 @@ def token_updater(token: str): session["oauth2_token"] = token -def make_session(token=None, state=None, scope=None) -> OAuth2Session: +def make_session( + token: Optional[Dict[str, str]], state=Optional[str], scope=Optional[List[str]] +) -> OAuth2Session: return OAuth2Session( client_id=OAUTH2_CLIENT_ID, token=token, @@ -176,8 +178,7 @@ async def callback(): @app.route("/guilds") @login_required async def guilds(): - guild_id = request.args.get("guild") - guild = get_guild_by_id(guild_id) + guild = get_guild_by_id(request.args.get("guild")) if guild: return redirect( @@ -212,9 +213,7 @@ async def subscribe(guild_id: str): if not any(str(guild.id) == user_guild["id"] for user_guild in user_guilds): return redirect(url_for(".login")) - user = discord.get(f"{API_BASE_URL}/users/@me").json() - - return await render_template("subscribe.html.j2", user=user, guild=guild) + return await render_template("subscribe.html.j2", guild=guild) @app.route("/.ics")