From 23c632b37b4618ca454234bdd986dedae8668853 Mon Sep 17 00:00:00 2001 From: Boger Date: Wed, 25 Mar 2020 15:57:25 +0300 Subject: [PATCH] Fix style errors --- aiogram/api/client/bot.py | 4 +--- aiogram/dispatcher/handler/base.py | 1 - aiogram/dispatcher/handler/message.py | 1 - aiogram/utils/mixins.py | 8 ++++---- tests/test_api/test_client/test_base_bot.py | 4 +--- .../test_client/test_session/test_base_session.py | 2 +- tests/test_utils/test_mixins.py | 2 +- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/aiogram/api/client/bot.py b/aiogram/api/client/bot.py index 5e58b4f8..00ec955d 100644 --- a/aiogram/api/client/bot.py +++ b/aiogram/api/client/bot.py @@ -111,9 +111,7 @@ from ..types import ( UserProfilePhotos, WebhookInfo, ) -from ...utils.mixins import ( - ContextInstanceMixin, -) +from ...utils.mixins import ContextInstanceMixin from ...utils.token import ( validate_token, extract_bot_id, diff --git a/aiogram/dispatcher/handler/base.py b/aiogram/dispatcher/handler/base.py index 45d3f28e..bf8f9785 100644 --- a/aiogram/dispatcher/handler/base.py +++ b/aiogram/dispatcher/handler/base.py @@ -1,6 +1,5 @@ from abc import ABC, abstractmethod from typing import ( - Optional, TYPE_CHECKING, Any, Dict, diff --git a/aiogram/dispatcher/handler/message.py b/aiogram/dispatcher/handler/message.py index 47ad54f3..7e7e0ab6 100644 --- a/aiogram/dispatcher/handler/message.py +++ b/aiogram/dispatcher/handler/message.py @@ -27,6 +27,5 @@ class MessageHandlerCommandMixin(BaseHandlerMixin[Message]): @property def command(self) -> Optional[CommandObject]: if "command" in self.data: - # TODO: remove cast return cast(CommandObject, self.data["command"]) return None diff --git a/aiogram/utils/mixins.py b/aiogram/utils/mixins.py index 2972e1b7..897502ab 100644 --- a/aiogram/utils/mixins.py +++ b/aiogram/utils/mixins.py @@ -58,16 +58,16 @@ class ContextInstanceMixin(Generic[ContextInstance]): @overload # noqa: F811, it's overload, not redefinition @classmethod - def get_current(cls, no_error: Literal[True]) -> Optional[ContextInstance]: + def get_current(cls, no_error: Literal[True]) -> Optional[ContextInstance]: # noqa: F811 ... - @overload # noqa: F811, it's overload, not redefinition + @overload # noqa: F811, it's overload, not redefinition @classmethod - def get_current(cls, no_error: Literal[False]) -> ContextInstance: + def get_current(cls, no_error: Literal[False]) -> ContextInstance: # noqa: F811 ... @classmethod # noqa: F811, it's overload, not redefinition - def get_current(cls, no_error: bool = True) -> Optional[ContextInstance]: + def get_current(cls, no_error: bool = True) -> Optional[ContextInstance]: # noqa: F811 # on mypy 0.770 I catch that contextvars.ContextVar always contextvars.ContextVar[Any] cls.__context_instance = cast( contextvars.ContextVar[ContextInstance], cls.__context_instance diff --git a/tests/test_api/test_client/test_base_bot.py b/tests/test_api/test_client/test_base_bot.py index a254bfaf..91c9f7c8 100644 --- a/tests/test_api/test_client/test_base_bot.py +++ b/tests/test_api/test_client/test_base_bot.py @@ -55,9 +55,7 @@ class TestBaseBot: with patch( "aiogram.api.client.session.aiohttp.AiohttpSession.close", new_callable=CoroutineMock ) as mocked_close: - async with Bot("42:TEST", session=AiohttpSession()).context( - auto_close=close - ) as bot: + async with Bot("42:TEST", session=AiohttpSession()).context(auto_close=close) as bot: assert isinstance(bot, Bot) if close: mocked_close.assert_awaited() diff --git a/tests/test_api/test_client/test_session/test_base_session.py b/tests/test_api/test_client/test_session/test_base_session.py index 422acd3b..4c86f9da 100644 --- a/tests/test_api/test_client/test_session/test_base_session.py +++ b/tests/test_api/test_client/test_session/test_base_session.py @@ -30,7 +30,7 @@ class CustomSession(BaseSession): yield b"\f" * 10 -class TestBaseSession(): +class TestBaseSession: def test_init_api(self): session = CustomSession() assert session.api == PRODUCTION diff --git a/tests/test_utils/test_mixins.py b/tests/test_utils/test_mixins.py index fe96b3e1..1f4805bd 100644 --- a/tests/test_utils/test_mixins.py +++ b/tests/test_utils/test_mixins.py @@ -6,7 +6,7 @@ from aiogram.utils.mixins import ( ) -class ContextObject(ContextInstanceMixin['ContextObject']): +class ContextObject(ContextInstanceMixin["ContextObject"]): pass