mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Fix style errors
This commit is contained in:
parent
7db1572fd3
commit
23c632b37b
7 changed files with 8 additions and 14 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import (
|
||||
Optional,
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Dict,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from aiogram.utils.mixins import (
|
|||
)
|
||||
|
||||
|
||||
class ContextObject(ContextInstanceMixin['ContextObject']):
|
||||
class ContextObject(ContextInstanceMixin["ContextObject"]):
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue