Skip to content

Commit

Permalink
drop support python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
chirizxc committed Nov 5, 2024
1 parent c5e24e4 commit a727f87
Show file tree
Hide file tree
Showing 68 changed files with 348 additions and 330 deletions.
1 change: 0 additions & 1 deletion .github/workflows/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
os:
- ubuntu-latest
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand Down
24 changes: 12 additions & 12 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath("."))

import datetime

# -- Project information -----------------------------------------------------

project = 'aiogram-dialog'
copyright = f'{datetime.date.today().year}, Tishka17'
author = 'Tishka17'
master_doc = 'index'
project = "aiogram-dialog"
copyright = f"{datetime.date.today().year}, Tishka17"
author = "Tishka17"
master_doc = "index"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx_copybutton',
"sphinx.ext.autodoc",
"sphinx_copybutton",
]
autodoc_type_aliases = {
}
autodoc_typehints = 'description'
autodoc_typehints = "description"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -49,9 +49,9 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'furo'
html_theme = "furo"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
2 changes: 1 addition & 1 deletion example/custom_media_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ async def main():
await dp.start_polling(bot)


if __name__ == '__main__':
if __name__ == "__main__":
asyncio.run(main())
2 changes: 1 addition & 1 deletion example/i18n/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ async def main():
await dp.start_polling(bot)


if __name__ == '__main__':
if __name__ == "__main__":
asyncio.run(main())
4 changes: 2 additions & 2 deletions example/i18n/i18n_format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Protocol
from typing import Any, Protocol

from aiogram_dialog.api.protocols import DialogManager
from aiogram_dialog.widgets.common import WhenCondition
Expand All @@ -21,7 +21,7 @@ def __init__(self, text: str, when: WhenCondition = None):
super().__init__(when)
self.text = text

async def _render_text(self, data: Dict, manager: DialogManager) -> str:
async def _render_text(self, data: dict, manager: DialogManager) -> str:
format_text = manager.middleware_data.get(
I18N_FORMAT_KEY, default_format_text,
)
Expand Down
7 changes: 4 additions & 3 deletions example/i18n/i18n_middleware.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Awaitable, Callable, Dict, Union
from typing import Any, Union
from collections.abc import Awaitable, Callable

from aiogram.dispatcher.middlewares.base import BaseMiddleware
from aiogram.types import CallbackQuery, Message
Expand All @@ -9,7 +10,7 @@
class I18nMiddleware(BaseMiddleware):
def __init__(
self,
l10ns: Dict[str, FluentLocalization],
l10ns: dict[str, FluentLocalization],
default_lang: str,
):
super().__init__()
Expand All @@ -19,7 +20,7 @@ def __init__(
async def __call__(
self,
handler: Callable[
[Union[Message, CallbackQuery], Dict[str, Any]],
[Union[Message, CallbackQuery], dict[str, Any]],
Awaitable[Any],
],
event: Union[Message, CallbackQuery],
Expand Down
2 changes: 1 addition & 1 deletion example/launch_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ async def main():
await dp.start_polling(bot)


if __name__ == '__main__':
if __name__ == "__main__":
asyncio.run(main())
5 changes: 2 additions & 3 deletions example/list_group.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import logging
import os
from typing import Dict

from aiogram import Bot, Dispatcher
from aiogram.filters import CommandStart
Expand All @@ -27,7 +26,7 @@ class DialogSG(StatesGroup):
greeting = State()


def when_checked(data: Dict, widget, manager: SubManager) -> bool:
def when_checked(data: dict, widget, manager: SubManager) -> bool:
# manager for our case is already adapted for current ListGroup row
# so `.find` returns widget adapted for current row
# if you need to find widgets outside the row, use `.find_in_parent`
Expand Down Expand Up @@ -98,5 +97,5 @@ async def main():
await dp.start_polling(bot)


if __name__ == '__main__':
if __name__ == "__main__":
asyncio.run(main())
2 changes: 1 addition & 1 deletion example/mega/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ async def main():
await dp.start_polling(bot)


if __name__ == '__main__':
if __name__ == "__main__":
asyncio.run(main())
7 changes: 3 additions & 4 deletions example/mega/bot_dialogs/calendar.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from datetime import date
from typing import Dict

from aiogram import F
from babel.dates import get_day_names, get_month_names
Expand All @@ -25,7 +24,7 @@ async def _render_text(self, data, manager: DialogManager) -> str:
selected_date: date = data["date"]
locale = manager.event.from_user.language_code
return get_day_names(
width="short", context='stand-alone', locale=locale,
width="short", context="stand-alone", locale=locale,
)[selected_date.weekday()].title()


Expand All @@ -49,12 +48,12 @@ async def _render_text(self, data, manager: DialogManager) -> str:
selected_date: date = data["date"]
locale = manager.event.from_user.language_code
return get_month_names(
'wide', context='stand-alone', locale=locale,
"wide", context="stand-alone", locale=locale,
)[selected_date.month].title()


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,
Expand Down
4 changes: 2 additions & 2 deletions example/mega/bot_dialogs/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict
from typing import Any

from aiogram_dialog import Dialog, DialogManager, Window
from aiogram_dialog.widgets.kbd import Back, Checkbox, Next, Radio, Row
Expand All @@ -14,7 +14,7 @@

async def data_getter(
dialog_manager: DialogManager, **_kwargs,
) -> Dict[str, Any]:
) -> dict[str, Any]:
return {
"option": dialog_manager.find(CHECKBOX_ID).is_checked(),
"emoji": dialog_manager.find(EMOJI_ID).get_checked(),
Expand Down
15 changes: 9 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=66.0"]
requires = ["setuptools==75.3.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
Expand All @@ -17,18 +17,21 @@ authors = [
]
license = { text = "Apache-2.0" }
description = "Telegram bot UI framework on top of aiogram"
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dependencies = [
'aiogram>=3.5.0',
'jinja2',
'cachetools>=4.0.0,<6.0.0',
'magic_filter',
"aiogram>=3.14.0",
"jinja2",
"cachetools>=4.0.0,<6.0.0",
]
[project.optional-dependencies]
tools = [
Expand Down
17 changes: 0 additions & 17 deletions requirements_dev.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements_doc.txt

This file was deleted.

2 changes: 1 addition & 1 deletion src/aiogram_dialog/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def about_dialog():
"<b>Author:</b> {{metadata['Author-email']}}\n"
"\n"
"{% for name, url in urls%}"
"<b>{{name}}:</b> <a href=\"{{url}}\">{{url}}</a>\n"
'<b>{{name}}:</b> <a href="{{url}}">{{url}}</a>\n'
"{% endfor %}"
"",
),
Expand Down
4 changes: 2 additions & 2 deletions src/aiogram_dialog/api/entities/access.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from dataclasses import dataclass
from typing import Any, List
from typing import Any


@dataclass
class AccessSettings:
user_ids: List[int]
user_ids: list[int]
custom: Any = None
6 changes: 3 additions & 3 deletions src/aiogram_dialog/api/entities/context.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Union
from typing import Optional, Union

from aiogram.fsm.state import State

from .access import AccessSettings

Data = Union[Dict, List, int, str, float, None]
DataDict = Dict[str, Data]
Data = Union[dict, list, int, str, float, None]
DataDict = dict[str, Data]


@dataclass(unsafe_hash=True)
Expand Down
4 changes: 2 additions & 2 deletions src/aiogram_dialog/api/entities/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import string
import time
from dataclasses import dataclass, field
from typing import List, Optional
from typing import Optional

from aiogram.fsm.state import State

Expand Down Expand Up @@ -38,7 +38,7 @@ def new_id():
@dataclass(unsafe_hash=True)
class Stack:
_id: str = field(compare=True, default_factory=new_id)
intents: List[str] = field(compare=False, default_factory=list)
intents: list[str] = field(compare=False, default_factory=list)
last_message_id: Optional[int] = field(compare=False, default=None)
last_reply_keyboard: bool = field(compare=False, default=False)
last_media_id: Optional[str] = field(compare=False, default=None)
Expand Down
4 changes: 2 additions & 2 deletions src/aiogram_dialog/api/internal/manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import abstractmethod
from typing import Dict, Protocol
from typing import Protocol

from aiogram import Router

Expand All @@ -12,7 +12,7 @@
class DialogManagerFactory(Protocol):
@abstractmethod
def __call__(
self, event: ChatEvent, data: Dict,
self, event: ChatEvent, data: dict,
registry: DialogRegistryProtocol,
router: Router,
) -> DialogManager:
Expand Down
11 changes: 6 additions & 5 deletions src/aiogram_dialog/api/internal/widgets.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from abc import abstractmethod
from typing import (
Any, Awaitable, Callable, Dict, List, Optional, Protocol,
Any, Optional, Protocol,
runtime_checkable, Union,
)
from collections.abc import Awaitable, Callable

from aiogram.types import (
CallbackQuery, InlineKeyboardButton, KeyboardButton, Message,
Expand All @@ -28,21 +29,21 @@ def find(self, widget_id: str) -> Optional["Widget"]:
class TextWidget(Widget, Protocol):
@abstractmethod
async def render_text(
self, data: Dict, manager: DialogManager,
self, data: dict, manager: DialogManager,
) -> str:
"""Create text."""
raise NotImplementedError


ButtonVariant = Union[InlineKeyboardButton, KeyboardButton]
RawKeyboard = List[List[ButtonVariant]]
RawKeyboard = list[list[ButtonVariant]]


@runtime_checkable
class KeyboardWidget(Widget, Protocol):
@abstractmethod
async def render_keyboard(
self, data: Dict, manager: DialogManager,
self, data: dict, manager: DialogManager,
) -> RawKeyboard:
"""Create Inline keyboard contents."""
raise NotImplementedError
Expand Down Expand Up @@ -89,7 +90,7 @@ async def process_message(
raise NotImplementedError


DataGetter = Callable[..., Awaitable[Dict]]
DataGetter = Callable[..., Awaitable[dict]]


@runtime_checkable
Expand Down
Loading

0 comments on commit a727f87

Please sign in to comment.