mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Reformat code
This commit is contained in:
parent
1034926286
commit
47bdad4098
35 changed files with 39 additions and 50 deletions
|
|
@ -17,8 +17,8 @@ from typing import (
|
|||
)
|
||||
|
||||
from aiogram.utils.exceptions import TelegramAPIError
|
||||
|
||||
from aiogram.utils.helper import Default
|
||||
|
||||
from ...methods import Response, TelegramMethod
|
||||
from ...types import UNSET
|
||||
from ..telegram import PRODUCTION, TelegramAPIServer
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from typing import Any, AsyncGenerator, Dict, Optional, Union
|
|||
from .. import loggers
|
||||
from ..client.bot import Bot
|
||||
from ..methods import TelegramMethod
|
||||
from ..types import Update, User
|
||||
from ..types import TelegramObject, Update, User
|
||||
from ..utils.exceptions import TelegramAPIError
|
||||
from .event.bases import UNHANDLED, SkipHandler
|
||||
from .event.telegram import TelegramEventObserver
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ from typing import Any, Dict, Match, Optional, Pattern, Sequence, Union, cast
|
|||
from pydantic import validator
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.types import Message
|
||||
from aiogram.dispatcher.filters import BaseFilter
|
||||
from aiogram.types import Message
|
||||
|
||||
CommandPatterType = Union[str, re.Pattern]
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ from typing import Any, Dict, Optional, Sequence, Union
|
|||
|
||||
from pydantic import validator
|
||||
|
||||
from ...types import Message
|
||||
from aiogram.types.message import ContentType
|
||||
|
||||
from ...types import Message
|
||||
from .base import BaseFilter
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from typing import Any, Dict, Optional, Sequence, Union
|
|||
|
||||
from pydantic import root_validator
|
||||
|
||||
from aiogram.types import CallbackQuery, InlineQuery, Message, Poll
|
||||
from aiogram.dispatcher.filters import BaseFilter
|
||||
from aiogram.types import CallbackQuery, InlineQuery, Message, Poll
|
||||
|
||||
TextType = str
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from abc import ABC
|
||||
from typing import Optional
|
||||
|
||||
from aiogram.types import CallbackQuery, Message, User
|
||||
from aiogram.dispatcher.handler import BaseHandler
|
||||
from aiogram.types import CallbackQuery, Message, User
|
||||
|
||||
|
||||
class CallbackQueryHandler(BaseHandler[CallbackQuery], ABC):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from abc import ABC
|
||||
|
||||
from aiogram.types import ChosenInlineResult, User
|
||||
from aiogram.dispatcher.handler import BaseHandler
|
||||
from aiogram.types import ChosenInlineResult, User
|
||||
|
||||
|
||||
class ChosenInlineResultHandler(BaseHandler[ChosenInlineResult], ABC):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from abc import ABC
|
||||
|
||||
from aiogram.types import InlineQuery, User
|
||||
from aiogram.dispatcher.handler import BaseHandler
|
||||
from aiogram.types import InlineQuery, User
|
||||
|
||||
|
||||
class InlineQueryHandler(BaseHandler[InlineQuery], ABC):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from abc import ABC
|
||||
from typing import Optional, cast
|
||||
|
||||
from aiogram.types import Chat, Message, User
|
||||
from aiogram.dispatcher.filters import CommandObject
|
||||
from aiogram.dispatcher.handler.base import BaseHandler, BaseHandlerMixin
|
||||
from aiogram.types import Chat, Message, User
|
||||
|
||||
|
||||
class MessageHandler(BaseHandler[Message], ABC):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from abc import ABC
|
||||
from typing import List
|
||||
|
||||
from aiogram.types import Poll, PollOption
|
||||
from aiogram.dispatcher.handler import BaseHandler
|
||||
from aiogram.types import Poll, PollOption
|
||||
|
||||
|
||||
class PollHandler(BaseHandler[Poll], ABC):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from abc import ABC
|
||||
|
||||
from aiogram.types import PreCheckoutQuery, User
|
||||
from aiogram.dispatcher.handler import BaseHandler
|
||||
from aiogram.types import PreCheckoutQuery, User
|
||||
|
||||
|
||||
class PreCheckoutQueryHandler(BaseHandler[PreCheckoutQuery], ABC):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from abc import ABC
|
||||
|
||||
from aiogram.types import ShippingQuery, User
|
||||
from aiogram.dispatcher.handler import BaseHandler
|
||||
from aiogram.types import ShippingQuery, User
|
||||
|
||||
|
||||
class ShippingQueryHandler(BaseHandler[ShippingQuery], ABC):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from contextlib import contextmanager
|
||||
from typing import Any, Awaitable, Callable, Dict, Iterator, Optional, Tuple
|
||||
|
||||
from aiogram.types import Chat, Update, User
|
||||
from aiogram.dispatcher.middlewares.base import BaseMiddleware
|
||||
from aiogram.types import Chat, Update, User
|
||||
|
||||
|
||||
class UserContextMiddleware(BaseMiddleware[Update]):
|
||||
|
|
|
|||
|
|
@ -3,10 +3,8 @@ from __future__ import annotations
|
|||
import warnings
|
||||
from typing import Any, Dict, Generator, List, Optional, Union
|
||||
|
||||
from ..types import TelegramObject, Update
|
||||
from ..utils.imports import import_module
|
||||
from ..utils.warnings import CodeHasNoEffect
|
||||
from .event.bases import UNHANDLED, SkipHandler
|
||||
from .event.event import EventObserver
|
||||
from .event.telegram import TelegramEventObserver
|
||||
from .filters import BUILTIN_FILTERS
|
||||
|
|
@ -186,17 +184,6 @@ class Router:
|
|||
for router in self.sub_routers:
|
||||
await router.emit_shutdown(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def update_handler(self) -> TelegramEventObserver:
|
||||
warnings.warn(
|
||||
"`Router.update_handler(...)` is deprecated and will be removed in version 3.2 "
|
||||
"use `Router.update(...)`",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
return self.update
|
||||
|
||||
@property
|
||||
def message_handler(self) -> TelegramEventObserver:
|
||||
warnings.warn(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import datetime
|
|||
from typing import TYPE_CHECKING, Optional, Union
|
||||
|
||||
from aiogram.utils import helper
|
||||
|
||||
from .base import TelegramObject
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, List, Optional, Union
|
|||
from pydantic import Field
|
||||
|
||||
from aiogram.utils import helper
|
||||
|
||||
from .base import UNSET, TelegramObject
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .base import MutableTelegramObject, TelegramObject
|
||||
from .base import MutableTelegramObject
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from .user import User
|
||||
|
|
|
|||
6
poetry.lock
generated
6
poetry.lock
generated
|
|
@ -337,7 +337,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
|||
|
||||
[[package]]
|
||||
name = "importlib-metadata"
|
||||
version = "1.7.0"
|
||||
version = "2.0.0"
|
||||
description = "Read metadata from Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
|
|
@ -1449,8 +1449,8 @@ imagesize = [
|
|||
{file = "imagesize-1.2.0.tar.gz", hash = "sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1"},
|
||||
]
|
||||
importlib-metadata = [
|
||||
{file = "importlib_metadata-1.7.0-py2.py3-none-any.whl", hash = "sha256:dc15b2969b4ce36305c51eebe62d418ac7791e9a157911d58bfb1f9ccd8e2070"},
|
||||
{file = "importlib_metadata-1.7.0.tar.gz", hash = "sha256:90bb658cdbbf6d1735b6341ce708fc7024a3e14e99ffdc5783edea9f9b077f83"},
|
||||
{file = "importlib_metadata-2.0.0-py2.py3-none-any.whl", hash = "sha256:cefa1a2f919b866c5beb7c9f7b0ebb4061f30a8a9bf16d609b000e2dfaceb9c3"},
|
||||
{file = "importlib_metadata-2.0.0.tar.gz", hash = "sha256:77a540690e24b0305878c37ffd421785a6f7e53c8b5720d211b211de8d0e95da"},
|
||||
]
|
||||
ipython = [
|
||||
{file = "ipython-7.19.0-py3-none-any.whl", hash = "sha256:c987e8178ced651532b3b1ff9965925bfd445c279239697052561a9ab806d28f"},
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ proxy = ["aiohttp-socks"]
|
|||
|
||||
[tool.black]
|
||||
line-length = 99
|
||||
target-version = ['py37', 'py38', 'py39']
|
||||
target-version = ['py37', 'py38']
|
||||
exclude = '''
|
||||
(
|
||||
\.eggs
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
from typing import AsyncContextManager, AsyncGenerator
|
||||
|
||||
from aiogram.client.session import aiohttp
|
||||
import aiohttp_socks
|
||||
import pytest
|
||||
from aresponses import ResponsesMockServer
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.client.session import aiohttp
|
||||
from aiogram.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.methods import Request, TelegramMethod
|
||||
from aiogram.types import InputFile
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ from typing import Any, Dict, Union
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import Update
|
||||
from aiogram.dispatcher.event.handler import CallableMixin, FilterObject, HandlerObject
|
||||
from aiogram.dispatcher.filters import Text
|
||||
from aiogram.dispatcher.filters.base import BaseFilter
|
||||
from aiogram.dispatcher.handler.base import BaseHandler
|
||||
from aiogram.types import Update
|
||||
|
||||
|
||||
def callback1(foo: int, bar: int, baz: int):
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ from typing import Any, Awaitable, Callable, Dict, NoReturn, Union
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import Chat, Message, User
|
||||
from aiogram.dispatcher.event.bases import SkipHandler
|
||||
from aiogram.dispatcher.event.handler import HandlerObject
|
||||
from aiogram.dispatcher.event.telegram import TelegramEventObserver
|
||||
from aiogram.dispatcher.filters.base import BaseFilter
|
||||
from aiogram.dispatcher.router import Router
|
||||
from aiogram.types import Chat, Message, User
|
||||
|
||||
# TODO: Test middlewares in routers tree
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ from typing import Match
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.dispatcher.filters import Command, CommandObject
|
||||
from aiogram.methods import GetMe
|
||||
from aiogram.types import Chat, Message, User
|
||||
from aiogram.dispatcher.filters import Command, CommandObject
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ from typing import cast
|
|||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from aiogram.types import ContentType, Message
|
||||
from aiogram.dispatcher.filters import ContentTypesFilter
|
||||
from aiogram.types import ContentType, Message
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ from typing import Sequence, Type
|
|||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from aiogram.types import CallbackQuery, Chat, InlineQuery, Message, Poll, PollOption, User
|
||||
from aiogram.dispatcher.filters import BUILTIN_FILTERS
|
||||
from aiogram.dispatcher.filters.text import Text
|
||||
from aiogram.types import CallbackQuery, Chat, InlineQuery, Message, Poll, PollOption, User
|
||||
|
||||
|
||||
class TestText:
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ from typing import Any
|
|||
import pytest
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.types import Chat, Message, Update
|
||||
from aiogram.dispatcher.event.handler import HandlerObject
|
||||
from aiogram.dispatcher.handler.base import BaseHandler
|
||||
from aiogram.types import Chat, Message, Update
|
||||
|
||||
|
||||
class MyHandler(BaseHandler):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import CallbackQuery, User
|
||||
from aiogram.dispatcher.handler import CallbackQueryHandler
|
||||
from aiogram.types import CallbackQuery, User
|
||||
|
||||
|
||||
class TestCallbackQueryHandler:
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import CallbackQuery, ChosenInlineResult, User
|
||||
from aiogram.dispatcher.handler import ChosenInlineResultHandler
|
||||
from aiogram.types import CallbackQuery, ChosenInlineResult, User
|
||||
|
||||
|
||||
class TestChosenInlineResultHandler:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.dispatcher.handler import ErrorHandler, PollHandler
|
||||
from aiogram.types import (
|
||||
CallbackQuery,
|
||||
InlineQuery,
|
||||
|
|
@ -11,7 +12,6 @@ from aiogram.types import (
|
|||
ShippingQuery,
|
||||
User,
|
||||
)
|
||||
from aiogram.dispatcher.handler import ErrorHandler, PollHandler
|
||||
|
||||
|
||||
class TestErrorHandler:
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import CallbackQuery, InlineQuery, User
|
||||
from aiogram.dispatcher.handler import InlineQueryHandler
|
||||
from aiogram.types import CallbackQuery, InlineQuery, User
|
||||
|
||||
|
||||
class TestCallbackQueryHandler:
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import Chat, Message, User
|
||||
from aiogram.dispatcher.filters import CommandObject
|
||||
from aiogram.dispatcher.handler.message import MessageHandler, MessageHandlerCommandMixin
|
||||
from aiogram.types import Chat, Message, User
|
||||
|
||||
|
||||
class MyHandler(MessageHandler):
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.dispatcher.handler import PollHandler
|
||||
from aiogram.types import (
|
||||
CallbackQuery,
|
||||
InlineQuery,
|
||||
|
|
@ -11,7 +12,6 @@ from aiogram.types import (
|
|||
ShippingQuery,
|
||||
User,
|
||||
)
|
||||
from aiogram.dispatcher.handler import PollHandler
|
||||
|
||||
|
||||
class TestShippingQueryHandler:
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import PreCheckoutQuery, User
|
||||
from aiogram.dispatcher.handler import PreCheckoutQueryHandler
|
||||
from aiogram.types import PreCheckoutQuery, User
|
||||
|
||||
|
||||
class TestPreCheckoutQueryHandler:
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.types import CallbackQuery, InlineQuery, ShippingAddress, ShippingQuery, User
|
||||
from aiogram.dispatcher.handler import ShippingQueryHandler
|
||||
from aiogram.types import CallbackQuery, InlineQuery, ShippingAddress, ShippingQuery, User
|
||||
|
||||
|
||||
class TestShippingQueryHandler:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ from typing import Any
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler, skip
|
||||
from aiogram.dispatcher.middlewares.user_context import UserContextMiddleware
|
||||
from aiogram.dispatcher.router import Router
|
||||
from aiogram.types import (
|
||||
CallbackQuery,
|
||||
Chat,
|
||||
|
|
@ -18,9 +21,6 @@ from aiogram.types import (
|
|||
Update,
|
||||
User,
|
||||
)
|
||||
from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler, skip
|
||||
from aiogram.dispatcher.middlewares.user_context import UserContextMiddleware
|
||||
from aiogram.dispatcher.router import Router
|
||||
from aiogram.utils.warnings import CodeHasNoEffect
|
||||
|
||||
importable_router = Router()
|
||||
|
|
@ -92,7 +92,6 @@ class TestRouter:
|
|||
assert router.observers["pre_checkout_query"] == router.pre_checkout_query
|
||||
assert router.observers["poll"] == router.poll
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_emit_startup(self):
|
||||
router1 = Router()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue