diff --git a/README.md b/README.md
index 5d0bae2e..48c834ce 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[](https://opensource.org/licenses/MIT)
[](https://pypi.python.org/pypi/aiogram)
-[](https://core.telegram.org/bots/api)
+[](https://core.telegram.org/bots/api)
[](https://pypi.python.org/pypi/aiogram)
[](https://pypi.python.org/pypi/aiogram)
[](https://pypi.python.org/pypi/aiogram)
diff --git a/aiogram/dispatcher/middlewares/base.py b/aiogram/dispatcher/middlewares/base.py
index f0db86ec..18611176 100644
--- a/aiogram/dispatcher/middlewares/base.py
+++ b/aiogram/dispatcher/middlewares/base.py
@@ -5,6 +5,10 @@ T = TypeVar("T")
class BaseMiddleware(ABC, Generic[T]):
+ """
+ Generic middleware class
+ """
+
@abstractmethod
async def __call__(
self,
@@ -12,4 +16,12 @@ class BaseMiddleware(ABC, Generic[T]):
event: T,
data: Dict[str, Any],
) -> Any: # pragma: no cover
+ """
+ Execute middleware
+
+ :param handler: Wrapped handler in middlewares chain
+ :param event: Incoming event (Subclass of :class:`aiogram.types.base.TelegramObject`)
+ :param data: Contextual data. Will be mapped to handler arguments
+ :return: :class:`Any`
+ """
pass
diff --git a/docs2/dispatcher/index.rst b/docs2/dispatcher/index.rst
index 8e1d1932..c2ce4960 100644
--- a/docs2/dispatcher/index.rst
+++ b/docs2/dispatcher/index.rst
@@ -23,3 +23,4 @@ Dispatcher is subclass of router and should be always is root router.
class_based_handlers/index
filters/index
filters/magic_filters
+ middlewares
diff --git a/docs2/index.rst b/docs2/index.rst
index 6cb3f1bb..7414b814 100644
--- a/docs2/index.rst
+++ b/docs2/index.rst
@@ -13,7 +13,7 @@ aiogram
:target: https://pypi.python.org/pypi/aiogram
:alt: Supported python versions
-.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-4.9-blue.svg?logo=telegram
+.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-5.2-blue.svg?logo=telegram
:target: https://core.telegram.org/bots/api
:alt: Telegram Bot API
diff --git a/docs2/install.rst b/docs2/install.rst
index c9e1cfe3..a5a1f8ee 100644
--- a/docs2/install.rst
+++ b/docs2/install.rst
@@ -12,53 +12,31 @@ Using PIP
pip install -U aiogram
+Using AUR
+---------
-Using poetry
-------------
+*aiogram* 2.x is also available in Arch Linux Repository, so you can install this framework
+on any Arch-based distribution like Arch Linux, Antergos, Manjaro, etc.
+
+To do this, just use pacman to install the *python-aiogram* package:
.. code-block:: bash
- poetry add aiogram
-
-
-Using Pipenv
-------------
-
-.. code-block:: bash
-
- pipenv install aiogram
-
-Using poetry
-------------
-
-.. code-block:: bash
-
- poetry add aiogram
-
-Using Pacman
-------------
-*aiogram* is also available in Arch Linux Repository, so you can install this framework on any
-Arch-based distribution like Arch Linux, Antergos, Manjaro, etc. To do this, just use pacman
-to install the `python-aiogram `_ package:
-
-.. code-block:: bash
-
- pacman -S python-aiogram
+ $ pacman -S python-aiogram
Development build (3.x)
=======================
-From private PyPi index
+From test PyPi index
-----------------------
-On every push to the `dev-3.x` branch GitHub Actions build the package and publish
-to the `2038.host `_ server with seems like official PyPi files structure.
-That's mean you can always install latest (may be unstable) build via next command:
-
.. code-block:: bash
- pip install --extra-index-url https://dev-docs.aiogram.dev/simple --pre aiogram
+ pip install -U --extra-index-url https://test.pypi.org/simple/ --pre aiogram
+From GitHub
+-----------
-In this repository available only last success build. All previous builds is always removes
-before uploading new one. Also before building this package all tests is also pass.
+.. code-block:: bash
+
+ pip install https://github.com/aiogram/aiogram/archive/refs/heads/dev-3.x.zip
diff --git a/scripts/bump_versions.py b/scripts/bump_versions.py
index 9ed20b68..28072c9c 100644
--- a/scripts/bump_versions.py
+++ b/scripts/bump_versions.py
@@ -6,6 +6,7 @@ import toml
BASE_PATTERN = r'({variable} = ")[a-z0-9.+]+(")'
PACKAGE_VERSION = re.compile(BASE_PATTERN.format(variable="__version__"))
API_VERSION = re.compile(BASE_PATTERN.format(variable="__api_version__"))
+API_VERSION_BADGE = re.compile(r"(API-)[\d.]+(-blue\.svg)")
STAGE_MAPPING = {
"alpha": "a",
@@ -37,7 +38,8 @@ def get_telegram_api_version() -> str:
def replace_line(content: str, pattern: re.Pattern, new_value: str) -> str:
- return pattern.sub(f"\\g<1>{new_value}\\g<2>", content)
+ result = pattern.sub(f"\\g<1>{new_value}\\g<2>", content)
+ return result
def write_package_meta(package_version: str, api_version: str) -> None:
@@ -51,6 +53,22 @@ def write_package_meta(package_version: str, api_version: str) -> None:
path.write_text(content)
+def write_readme(package_version: str, api_version: str) -> None:
+ path = Path.cwd() / "README.md"
+ content = path.read_text()
+ content = replace_line(content, API_VERSION_BADGE, api_version)
+ print(f"Write {path}")
+ path.write_text(content)
+
+
+def write_docs_index(package_version: str, api_version: str) -> None:
+ path = Path.cwd() / "docs2" / "index.rst"
+ content = path.read_text()
+ content = replace_line(content, API_VERSION_BADGE, api_version)
+ print(f"Write {path}")
+ path.write_text(content)
+
+
def write_docs_meta(package_version: str, api_version: str) -> None:
api_meta = Path.cwd() / "docs" / "_api_version.md"
package_meta = Path.cwd() / "docs" / "_package_version.md"
@@ -69,6 +87,8 @@ def main():
print(f"Telegram Bot API version: {api_version}")
write_package_meta(package_version=package_version, api_version=api_version)
write_docs_meta(package_version=package_version, api_version=api_version)
+ write_readme(package_version=package_version, api_version=api_version)
+ write_docs_index(package_version=package_version, api_version=api_version)
if __name__ == "__main__":
diff --git a/tests/test_api/test_types/test_message.py b/tests/test_api/test_types/test_message.py
index 15ea6087..5e56ed8a 100644
--- a/tests/test_api/test_types/test_message.py
+++ b/tests/test_api/test_types/test_message.py
@@ -1,9 +1,10 @@
import datetime
-from typing import Any, Dict, Type, Union, Optional
+from typing import Any, Dict, Optional, Type, Union
import pytest
from aiogram.methods import (
+ CopyMessage,
SendAnimation,
SendAudio,
SendContact,
@@ -21,7 +22,6 @@ from aiogram.methods import (
SendVideo,
SendVideoNote,
SendVoice,
- CopyMessage,
TelegramMethod,
)
from aiogram.types import (
@@ -35,6 +35,7 @@ from aiogram.types import (
Game,
Invoice,
Location,
+ MessageAutoDeleteTimerChanged,
PassportData,
PhotoSize,
Poll,
@@ -46,10 +47,9 @@ from aiogram.types import (
Video,
VideoNote,
Voice,
- MessageAutoDeleteTimerChanged,
- VoiceChatStarted,
VoiceChatEnded,
VoiceChatParticipantsInvited,
+ VoiceChatStarted,
)
from aiogram.types.message import ContentType, Message
@@ -71,7 +71,11 @@ TEST_MESSAGE_ANIMATION = Message(
message_id=42,
date=datetime.datetime.now(),
animation=Animation(
- file_id="file id", file_unique_id="file id", width=42, height=42, duration=0,
+ file_id="file id",
+ file_unique_id="file id",
+ width=42,
+ height=42,
+ duration=0,
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
@@ -106,7 +110,11 @@ TEST_MESSAGE_STICKER = Message(
message_id=42,
date=datetime.datetime.now(),
sticker=Sticker(
- file_id="file id", file_unique_id="file id", width=42, height=42, is_animated=False,
+ file_id="file id",
+ file_unique_id="file id",
+ width=42,
+ height=42,
+ is_animated=False,
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
@@ -114,7 +122,13 @@ TEST_MESSAGE_STICKER = Message(
TEST_MESSAGE_VIDEO = Message(
message_id=42,
date=datetime.datetime.now(),
- video=Video(file_id="file id", file_unique_id="file id", width=42, height=42, duration=0,),
+ video=Video(
+ file_id="file id",
+ file_unique_id="file id",
+ width=42,
+ height=42,
+ duration=0,
+ ),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
)
@@ -264,7 +278,8 @@ TEST_MESSAGE_PASSPORT_DATA = Message(
message_id=42,
date=datetime.datetime.now(),
passport_data=PassportData(
- data=[], credentials=EncryptedCredentials(data="test", hash="test", secret="test"),
+ data=[],
+ credentials=EncryptedCredentials(data="test", hash="test", secret="test"),
),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
@@ -275,7 +290,10 @@ TEST_MESSAGE_POLL = Message(
poll=Poll(
id="QA",
question="Q",
- options=[PollOption(text="A", voter_count=0), PollOption(text="B", voter_count=0),],
+ options=[
+ PollOption(text="A", voter_count=0),
+ PollOption(text="B", voter_count=0),
+ ],
is_closed=False,
is_anonymous=False,
type="quiz",
@@ -410,7 +428,12 @@ class TestMessage:
["sticker", dict(sticker="sticker"), SendSticker],
[
"venue",
- dict(latitude=0.42, longitude=0.42, title="title", address="address",),
+ dict(
+ latitude=0.42,
+ longitude=0.42,
+ title="title",
+ address="address",
+ ),
SendVenue,
],
["video", dict(video="video"), SendVideo],
@@ -513,7 +536,9 @@ class TestMessage:
],
)
def test_send_copy(
- self, message: Message, expected_method: Optional[Type[TelegramMethod]],
+ self,
+ message: Message,
+ expected_method: Optional[Type[TelegramMethod]],
):
if expected_method is None:
with pytest.raises(TypeError, match="This type of message can't be copied."):
diff --git a/tests/test_dispatcher/test_dispatcher.py b/tests/test_dispatcher/test_dispatcher.py
index 6c5280b7..da04527b 100644
--- a/tests/test_dispatcher/test_dispatcher.py
+++ b/tests/test_dispatcher/test_dispatcher.py
@@ -15,6 +15,8 @@ from aiogram.methods import GetMe, GetUpdates, SendMessage
from aiogram.types import (
CallbackQuery,
Chat,
+ ChatMember,
+ ChatMemberUpdated,
ChosenInlineResult,
InlineQuery,
Message,
@@ -26,8 +28,6 @@ from aiogram.types import (
ShippingQuery,
Update,
User,
- ChatMemberUpdated,
- ChatMember,
)
from tests.mocked_bot import MockedBot