From dfd4478977fce46dae1c1f5eb4e02ba97366e230 Mon Sep 17 00:00:00 2001 From: GregoryKogan Date: Thu, 30 Jun 2022 19:29:27 +0300 Subject: [PATCH] Null safety bug fixed --- src/questionnaire/data_preview.py | 4 ++-- src/questionnaire/dialog.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/questionnaire/data_preview.py b/src/questionnaire/data_preview.py index 8d90326..1c79078 100644 --- a/src/questionnaire/data_preview.py +++ b/src/questionnaire/data_preview.py @@ -27,10 +27,10 @@ def get_user_data_preview(user_id: int) -> str: return data -def get_check_data(user_id: int) -> (str, float): +def get_check_data(user_id: int) -> (str, float) or None: user_data = db.users_table.get(user_id) if user_data is None: - return "" + return None total_price = SHIRT_PRICE data = f"Футболка '120' - {SHIRT_PRICE}р." diff --git a/src/questionnaire/dialog.py b/src/questionnaire/dialog.py index fe891af..f6c67aa 100644 --- a/src/questionnaire/dialog.py +++ b/src/questionnaire/dialog.py @@ -136,7 +136,10 @@ async def skip_instagram(update, _): async def get_verification(update, _): if update.message.text == "Все верно": - message, amount = get_check_data(update.effective_user.id) + check_data = get_check_data(update.effective_user.id) + if check_data is None: + return ConversationHandler.END + message, amount = check_data await update.message.reply_text( text=message, reply_markup=go_to_payment(amount),