Fix style errors

This commit is contained in:
Boger 2020-03-25 15:57:25 +03:00
parent 7db1572fd3
commit 23c632b37b
7 changed files with 8 additions and 14 deletions

View file

@ -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,

View file

@ -1,6 +1,5 @@
from abc import ABC, abstractmethod
from typing import (
Optional,
TYPE_CHECKING,
Any,
Dict,

View file

@ -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

View file

@ -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

View file

@ -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()

View file

@ -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

View file

@ -6,7 +6,7 @@ from aiogram.utils.mixins import (
)
class ContextObject(ContextInstanceMixin['ContextObject']):
class ContextObject(ContextInstanceMixin["ContextObject"]):
pass