Skip to content

Commit 068749a

Browse files
authored
Improve the Django app example to be more robust (#523)
1 parent 1b5f4a1 commit 068749a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

examples/django/oauth_app/slack_datastores.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ def save(self, installation: Installation):
3333
i = installation.to_dict()
3434
if is_naive(i["installed_at"]):
3535
i["installed_at"] = make_aware(i["installed_at"])
36-
if "bot_token_expires_at" in i and is_naive(i["bot_token_expires_at"]):
36+
if i.get("bot_token_expires_at") is not None and is_naive(
37+
i["bot_token_expires_at"]
38+
):
3739
i["bot_token_expires_at"] = make_aware(i["bot_token_expires_at"])
38-
if "user_token_expires_at" in i and is_naive(i["user_token_expires_at"]):
40+
if i.get("user_token_expires_at") is not None and is_naive(
41+
i["user_token_expires_at"]
42+
):
3943
i["user_token_expires_at"] = make_aware(i["user_token_expires_at"])
4044
i["client_id"] = self.client_id
4145
row_to_update = (
@@ -58,7 +62,7 @@ def save_bot(self, bot: Bot):
5862
b = bot.to_dict()
5963
if is_naive(b["installed_at"]):
6064
b["installed_at"] = make_aware(b["installed_at"])
61-
if "bot_token_expires_at" in b is not None and is_naive(
65+
if b.get("bot_token_expires_at") is not None and is_naive(
6266
b["bot_token_expires_at"]
6367
):
6468
b["bot_token_expires_at"] = make_aware(b["bot_token_expires_at"])

0 commit comments

Comments
 (0)