Skip to content

Commit 221d81b

Browse files
committed
flake8 fix
1 parent cea867a commit 221d81b

File tree

10 files changed

+50
-30
lines changed

10 files changed

+50
-30
lines changed

pybotx/async_buffer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ async def seek(
1313
self,
1414
cursor: int,
1515
whence: int = os.SEEK_SET,
16-
) -> int: ... # noqa: WPS428
16+
) -> int: ... # noqa: WPS428, E704
1717

18-
async def tell(self) -> int: ... # noqa: WPS428
18+
async def tell(self) -> int: ... # noqa: WPS428, E704
1919

2020

2121
class AsyncBufferWritable(AsyncBufferBase):
2222
@abc.abstractmethod
23-
async def write(self, content: bytes) -> int: ... # noqa: WPS428
23+
async def write(self, content: bytes) -> int: ... # noqa: WPS428, E704
2424

2525

2626
class AsyncBufferReadable(AsyncBufferBase):
2727
@abc.abstractmethod
2828
async def read(
2929
self,
3030
bytes_to_read: Optional[int] = None,
31-
) -> bytes: ... # noqa: WPS428
31+
) -> bytes: ... # noqa: WPS428, E704
3232

3333

3434
async def get_file_size(async_buffer: AsyncBufferReadable) -> int:

pybotx/bot/callbacks/callback_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ def setup_callback_timeout_alarm(self, sync_id: UUID, timeout: float) -> None:
6969
def cancel_callback_timeout_alarm(
7070
self,
7171
sync_id: UUID,
72-
) -> None: ... # noqa: WPS428
72+
) -> None: ... # noqa: WPS428, E704
7373

7474
@overload
7575
def cancel_callback_timeout_alarm(
7676
self,
7777
sync_id: UUID,
7878
return_remaining_time: Literal[True],
79-
) -> float: ... # noqa: WPS428
79+
) -> float: ... # noqa: WPS428, E704
8080

8181
def cancel_callback_timeout_alarm(
8282
self,

pybotx/bot/callbacks/callback_repo_proto.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ class CallbackRepoProto(Protocol):
1616
async def create_botx_method_callback(
1717
self,
1818
sync_id: UUID,
19-
) -> None: ... # noqa: WPS428
19+
) -> None: ... # noqa: WPS428, E704
2020

2121
async def set_botx_method_callback_result(
2222
self,
2323
callback: BotXMethodCallback,
24-
) -> None: ... # noqa: WPS428
24+
) -> None: ... # noqa: WPS428, E704
2525

2626
async def wait_botx_method_callback(
2727
self,
2828
sync_id: UUID,
2929
timeout: float,
30-
) -> BotXMethodCallback: ... # noqa: WPS428
30+
) -> BotXMethodCallback: ... # noqa: WPS428, E704
3131

3232
async def pop_botx_method_callback(
3333
self,
3434
sync_id: UUID,
35-
) -> "Future[BotXMethodCallback]": ... # noqa: WPS428
35+
) -> "Future[BotXMethodCallback]": ... # noqa: WPS428, E704
3636

37-
async def stop_callbacks_waiting(self) -> None: ... # noqa: WPS428
37+
async def stop_callbacks_waiting(self) -> None: ... # noqa: WPS428, E704

pybotx/bot/handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ async def __call__(self, message: IncomingMessage, bot: "Bot") -> None:
7878
handler_func = self.handler_func
7979

8080
for middleware in self.middlewares[::-1]:
81-
handler_func = cast(HandlerFunc, partial(middleware, call_next=handler_func)) # type: ignore[type-arg, call-arg]
81+
handler_func = cast(
82+
HandlerFunc,
83+
partial(middleware, call_next=handler_func),
84+
) # type: ignore[type-arg, call-arg]
8285

8386
await handler_func(message, bot)
8487

pybotx/bot/handler_collector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def decorator(
194194
def default_message_handler(
195195
self,
196196
handler_func: IncomingMessageHandlerFunc,
197-
) -> IncomingMessageHandlerFunc: ... # noqa: WPS428
197+
) -> IncomingMessageHandlerFunc: ... # noqa: WPS428, E704
198198

199199
@overload
200200
def default_message_handler(
@@ -204,7 +204,7 @@ def default_message_handler(
204204
) -> Callable[
205205
[IncomingMessageHandlerFunc],
206206
IncomingMessageHandlerFunc,
207-
]: ... # noqa: WPS428
207+
]: ... # noqa: WPS428, E704
208208

209209
def default_message_handler( # noqa: WPS320
210210
self,

pybotx/models/attachments.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,10 @@ def convert_api_attachment_to_domain( # noqa: WPS212
220220
attachment_type = convert_attachment_type_to_domain(api_attachment.type)
221221

222222
if attachment_type == AttachmentTypes.IMAGE:
223-
attachment_type = cast(Literal[AttachmentTypes.IMAGE], attachment_type) # type: ignore[redundant-cast]
223+
attachment_type = cast(
224+
Literal[AttachmentTypes.IMAGE],
225+
attachment_type,
226+
) # type: ignore[redundant-cast]
224227
api_attachment = cast(BotAPIAttachmentImage, api_attachment)
225228
content = decode_rfc2397(api_attachment.data.content)
226229

@@ -233,7 +236,10 @@ def convert_api_attachment_to_domain( # noqa: WPS212
233236
)
234237

235238
if attachment_type == AttachmentTypes.VIDEO:
236-
attachment_type = cast(Literal[AttachmentTypes.VIDEO], attachment_type) # type: ignore[redundant-cast]
239+
attachment_type = cast(
240+
Literal[AttachmentTypes.VIDEO],
241+
attachment_type,
242+
) # type: ignore[redundant-cast]
237243
api_attachment = cast(BotAPIAttachmentVideo, api_attachment)
238244
content = decode_rfc2397(api_attachment.data.content)
239245

@@ -247,7 +253,10 @@ def convert_api_attachment_to_domain( # noqa: WPS212
247253
)
248254

249255
if attachment_type == AttachmentTypes.DOCUMENT:
250-
attachment_type = cast(Literal[AttachmentTypes.DOCUMENT], attachment_type) # type: ignore[redundant-cast]
256+
attachment_type = cast(
257+
Literal[AttachmentTypes.DOCUMENT],
258+
attachment_type,
259+
) # type: ignore[redundant-cast]
251260
api_attachment = cast(BotAPIAttachmentDocument, api_attachment)
252261
content = decode_rfc2397(api_attachment.data.content)
253262

@@ -260,7 +269,10 @@ def convert_api_attachment_to_domain( # noqa: WPS212
260269
)
261270

262271
if attachment_type == AttachmentTypes.VOICE:
263-
attachment_type = cast(Literal[AttachmentTypes.VOICE], attachment_type) # type: ignore[redundant-cast]
272+
attachment_type = cast(
273+
Literal[AttachmentTypes.VOICE],
274+
attachment_type,
275+
) # type: ignore[redundant-cast]
264276
api_attachment = cast(BotAPIAttachmentVoice, api_attachment)
265277
content = decode_rfc2397(api_attachment.data.content)
266278
attachment_extension = get_attachment_extension_from_encoded_content(
@@ -277,7 +289,10 @@ def convert_api_attachment_to_domain( # noqa: WPS212
277289
)
278290

279291
if attachment_type == AttachmentTypes.LOCATION:
280-
attachment_type = cast(Literal[AttachmentTypes.LOCATION], attachment_type) # type: ignore[redundant-cast]
292+
attachment_type = cast(
293+
Literal[AttachmentTypes.LOCATION],
294+
attachment_type,
295+
) # type: ignore[redundant-cast]
281296
api_attachment = cast(BotAPIAttachmentLocation, api_attachment)
282297

283298
return Location(
@@ -288,7 +303,10 @@ def convert_api_attachment_to_domain( # noqa: WPS212
288303
)
289304

290305
if attachment_type == AttachmentTypes.CONTACT:
291-
attachment_type = cast(Literal[AttachmentTypes.CONTACT], attachment_type) # type: ignore[redundant-cast]
306+
attachment_type = cast(
307+
Literal[AttachmentTypes.CONTACT],
308+
attachment_type,
309+
) # type: ignore[redundant-cast]
292310
api_attachment = cast(BotAPIAttachmentContact, api_attachment)
293311

294312
return Contact(

pybotx/models/chats.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from dataclasses import dataclass
22
from datetime import datetime
3-
from datetime import datetime as dt
43
from typing import List, Optional
54
from uuid import UUID
65

@@ -72,7 +71,7 @@ class ChatInfo:
7271
creator_id: Optional[UUID]
7372
description: Optional[str]
7473
chat_id: UUID
75-
created_at: dt
74+
created_at: datetime
7675
members: List[ChatInfoMember]
7776
name: str
7877
shared_history: bool

pybotx/models/enums.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ def convert_chat_type_from_domain(chat_type: ChatTypes) -> APIChatTypes:
307307
@overload
308308
def convert_chat_type_to_domain(
309309
chat_type: APIChatTypes,
310-
) -> ChatTypes: ... # noqa: WPS428
310+
) -> ChatTypes: ... # noqa: WPS428, E704
311311

312312

313313
@overload
314-
def convert_chat_type_to_domain(chat_type: str) -> UNSUPPORTED: ... # noqa: WPS428
314+
def convert_chat_type_to_domain(chat_type: str) -> UNSUPPORTED: ... # noqa: WPS428, E704
315315

316316

317317
def convert_chat_type_to_domain(
@@ -338,13 +338,13 @@ def convert_chat_type_to_domain(
338338
@overload
339339
def convert_sync_source_type_to_domain(
340340
sync_type: APISyncSourceTypes,
341-
) -> SyncSourceTypes: ... # noqa: WPS428
341+
) -> SyncSourceTypes: ... # noqa: WPS428, E704
342342

343343

344344
@overload
345345
def convert_sync_source_type_to_domain(
346346
sync_type: str,
347-
) -> UNSUPPORTED: ... # noqa: WPS428
347+
) -> UNSUPPORTED: ... # noqa: WPS428, E704
348348

349349

350350
def convert_sync_source_type_to_domain(

tests/test_handler_collector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,6 @@ async def test__handler_collector__sync_smartapp_event__decorator__handler_alrea
560560
with pytest.raises(ValueError) as exc:
561561

562562
@collector.sync_smartapp_event
563-
async def duplicated_handle_sync_smartapp_event(*_: Any) -> Any: ...
563+
async def duplicated_handle_sync_smartapp_event(*_: Any) -> Any: ... # noqa: E704
564564

565565
assert str(exc.value) == "Handler for sync smartapp event already registered"

tests/test_middlewares.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def middleware(
3535
bot: Bot,
3636
call_next: IncomingMessageHandlerFunc,
3737
) -> None:
38-
nonlocal middlewares_called_order
38+
# middlewares_called_order is already accessible in this scope
3939
middlewares_called_order.append(number)
4040

4141
await call_next(message, bot)
@@ -84,7 +84,7 @@ async def middleware(
8484
bot: Bot,
8585
call_next: IncomingMessageHandlerFunc,
8686
) -> None:
87-
nonlocal middlewares_called_order
87+
# middlewares_called_order is already accessible in this scope
8888
middlewares_called_order.append(number)
8989

9090
await call_next(message, bot)
@@ -129,7 +129,7 @@ async def middleware(
129129
bot: Bot,
130130
call_next: IncomingMessageHandlerFunc,
131131
) -> None:
132-
nonlocal middlewares_called_order
132+
# middlewares_called_order is already accessible in this scope
133133
middlewares_called_order.append(number)
134134

135135
await call_next(message, bot)

0 commit comments

Comments
 (0)