From fc7e852a3e0112a5b838f37bc8f5e5bafdc4b01a Mon Sep 17 00:00:00 2001 From: chiri <2alivemafia@gmail.com> Date: Wed, 6 Nov 2024 17:39:41 +0300 Subject: [PATCH] drop python 3.8 from docs examples --- .../example.py | 18 ++++++++--------- docs/widgets/hiding/example.py | 12 +++++------ docs/widgets/keyboard/calendar/custom.py | 15 ++++++++------ docs/widgets/text/case/example.py | 20 +++++++++---------- 4 files changed, 32 insertions(+), 33 deletions(-) diff --git a/docs/widgets/custom_widgets/switch_inline_query_current_chat/example.py b/docs/widgets/custom_widgets/switch_inline_query_current_chat/example.py index d62182d4..ddd57de0 100644 --- a/docs/widgets/custom_widgets/switch_inline_query_current_chat/example.py +++ b/docs/widgets/custom_widgets/switch_inline_query_current_chat/example.py @@ -1,9 +1,7 @@ -from typing import Dict, List - -from aiogram.filters.state import StatesGroup, State +from aiogram.filters.state import State, StatesGroup from aiogram.types import InlineKeyboardButton -from aiogram_dialog import Dialog, Window -from aiogram_dialog import DialogManager + +from aiogram_dialog import Dialog, DialogManager, Window from aiogram_dialog.widgets.kbd import SwitchInlineQuery from aiogram_dialog.widgets.text import Const @@ -11,9 +9,9 @@ class SwitchInlineQueryCurrentChat(SwitchInlineQuery): async def _render_keyboard( self, - data: Dict, + data: dict, manager: DialogManager, - ) -> List[List[InlineKeyboardButton]]: + ) -> list[list[InlineKeyboardButton]]: return [ [ InlineKeyboardButton( @@ -34,8 +32,8 @@ class MySG(StatesGroup): Window( SwitchInlineQueryCurrentChat( Const("Some search"), # Button text - Const("query") # additional query. Optional + Const("query"), # additional query. Optional ), - state=MySG.main - ) + state=MySG.main, + ), ) diff --git a/docs/widgets/hiding/example.py b/docs/widgets/hiding/example.py index de3cd53a..5b1c777a 100644 --- a/docs/widgets/hiding/example.py +++ b/docs/widgets/hiding/example.py @@ -1,11 +1,9 @@ -from typing import Dict - -from aiogram.filters.state import StatesGroup, State +from aiogram.filters.state import State, StatesGroup from magic_filter import F -from aiogram_dialog import Window, DialogManager +from aiogram_dialog import DialogManager, Window from aiogram_dialog.widgets.common import Whenable -from aiogram_dialog.widgets.kbd import Button, Row, Group +from aiogram_dialog.widgets.kbd import Button, Group, Row from aiogram_dialog.widgets.text import Const, Format, Multi @@ -20,7 +18,7 @@ async def get_data(**kwargs): } -def is_tishka17(data: Dict, widget: Whenable, manager: DialogManager): +def is_tishka17(data: dict, widget: Whenable, manager: DialogManager): return data.get("name") == "Tishka17" @@ -28,7 +26,7 @@ def is_tishka17(data: Dict, widget: Whenable, manager: DialogManager): Multi( Const("Hello"), Format("{name}", when="extended"), - sep=" " + sep=" ", ), Group( Row( diff --git a/docs/widgets/keyboard/calendar/custom.py b/docs/widgets/keyboard/calendar/custom.py index d3eb30aa..efb8a1b0 100644 --- a/docs/widgets/keyboard/calendar/custom.py +++ b/docs/widgets/keyboard/calendar/custom.py @@ -1,17 +1,20 @@ -from typing import Dict - from aiogram_dialog import DialogManager from aiogram_dialog.widgets.kbd import ( - Calendar, CalendarScope, CalendarUserConfig, + Calendar, + CalendarScope, + CalendarUserConfig, ) from aiogram_dialog.widgets.kbd.calendar_kbd import ( - CalendarDaysView, CalendarMonthView, CalendarScopeView, CalendarYearsView, + CalendarDaysView, + CalendarMonthView, + CalendarScopeView, + CalendarYearsView, ) from aiogram_dialog.widgets.text import Const, Format class CustomCalendar(Calendar): - def _init_views(self) -> Dict[CalendarScope, CalendarScopeView]: + def _init_views(self) -> dict[CalendarScope, CalendarScopeView]: return { CalendarScope.DAYS: CalendarDaysView( self._item_callback_data, self.config, @@ -28,7 +31,7 @@ def _init_views(self) -> Dict[CalendarScope, CalendarScopeView]: async def _get_user_config( self, - data: Dict, + data: dict, manager: DialogManager, ) -> CalendarUserConfig: return CalendarUserConfig( diff --git a/docs/widgets/text/case/example.py b/docs/widgets/text/case/example.py index 0181477a..cbe72d5e 100644 --- a/docs/widgets/text/case/example.py +++ b/docs/widgets/text/case/example.py @@ -1,11 +1,11 @@ -from typing import Any, Dict +from typing import Any +from aiogram.filters.state import State, StatesGroup from magic_filter import F -from aiogram.filters.state import StatesGroup, State +from aiogram_dialog import Dialog, DialogManager, Window +from aiogram_dialog.widgets.text import Case, Const, Format -from aiogram_dialog import Window, DialogManager, Dialog -from aiogram_dialog.widgets.text import Const, Format, Case class MySG(StatesGroup): window1 = State() @@ -35,7 +35,7 @@ async def get_data(**kwargs): # The result of this function will be used to select wich option of ``Case`` widget to show. # # `text2` will produce text `42 is even!` -def parity_selector(data: Dict, case: Case, manager: DialogManager): +def parity_selector(data: dict, case: Case, manager: DialogManager): return data["number"] % 2 @@ -63,8 +63,8 @@ def parity_selector(data: Dict, case: Case, manager: DialogManager): async def on_dialog_start(start_data: Any, manager: DialogManager): - manager.dialog_data['user'] = { - 'test_result': True, + manager.dialog_data["user"] = { + "test_result": True, } @@ -74,7 +74,7 @@ async def on_dialog_start(start_data: Any, manager: DialogManager): text2, text3, state=MySG.window1, - getter=get_data + getter=get_data, ), - on_start=on_dialog_start -) \ No newline at end of file + on_start=on_dialog_start, +)