Skip to content

Commit

Permalink
Merge pull request #438 from chirizxc/develop
Browse files Browse the repository at this point in the history
drop python 3.8 from docs examples
  • Loading branch information
Tishka17 authored Nov 6, 2024
2 parents d951f7e + fc7e852 commit 508a133
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
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


class SwitchInlineQueryCurrentChat(SwitchInlineQuery):
async def _render_keyboard(
self,
data: Dict,
data: dict,
manager: DialogManager,
) -> List[List[InlineKeyboardButton]]:
) -> list[list[InlineKeyboardButton]]:
return [
[
InlineKeyboardButton(
Expand All @@ -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,
),
)
12 changes: 5 additions & 7 deletions docs/widgets/hiding/example.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -20,15 +18,15 @@ 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"


window = Window(
Multi(
Const("Hello"),
Format("{name}", when="extended"),
sep=" "
sep=" ",
),
Group(
Row(
Expand Down
15 changes: 9 additions & 6 deletions docs/widgets/keyboard/calendar/custom.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(
Expand Down
20 changes: 10 additions & 10 deletions docs/widgets/text/case/example.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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,
}


Expand All @@ -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
)
on_start=on_dialog_start,
)

0 comments on commit 508a133

Please sign in to comment.