Skip to content

Commit

Permalink
some ruff fix
Browse files Browse the repository at this point in the history
  • Loading branch information
5hojib committed Dec 8, 2024
1 parent 854e52d commit 38d55bf
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 20 deletions.
7 changes: 4 additions & 3 deletions bot/helper/ext_utils/status_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
from asyncio import iscoroutinefunction
from html import escape
from time import time
Expand Down Expand Up @@ -269,11 +270,11 @@ def source(self):
)


async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=1):
async def get_readable_message(sid, is_user, page_no=1, status="All"):
msg = ""
button = None

tasks = await sync_to_async(getSpecificTasks, status, sid if is_user else None)
tasks = await sync_to_async(get_specific_tasks, status, sid if is_user else None)

STATUS_LIMIT = 4
tasks_no = len(tasks)
Expand Down Expand Up @@ -310,7 +311,7 @@ async def get_readable_message(sid, is_user, page_no=1, status="All", page_step=
msg += f"\n{task.processed_bytes()} of {task.size()}"
msg += f"\n<b>Speed:</b> {task.speed()}\n<b>Estimated:</b> {task.eta()}"
if hasattr(task, "seeders_num"):
with suppress(Exception):
with contextlib.suppress(Exception):
msg += f"\n<b>Seeders:</b> {task.seeders_num()} <b>Leechers:</b> {task.leechers_num()}"
elif tstatus == MirrorStatus.STATUS_SEEDING:
msg += f"\n<b>Size: </b>{task.size()}"
Expand Down
17 changes: 9 additions & 8 deletions bot/helper/listeners/qbit_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,15 @@ async def _on_seed_finish(tor):

@new_task
async def _stop_duplicate(tor):
if task := await get_task_by_gid(tor.hash[:12]) and task.listener.stop_duplicate:
task.listener.name = tor.content_path.rsplit("/", 1)[-1].rsplit(
".!qB",
1,
)[0]
msg, button = await stop_duplicate_check(task.listener)
if msg:
_on_download_error(msg, tor, button)
if task := await get_task_by_gid(tor.hash[:12]):
if task.listener.stop_duplicate:
task.listener.name = tor.content_path.rsplit("/", 1)[-1].rsplit(
".!qB",
1,
)[0]
msg, button = await stop_duplicate_check(task.listener)
if msg:
_on_download_error(msg, tor, button)


@new_task
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: ARG005
import contextlib
from logging import getLogger
from os import listdir
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/gdrive_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ async def get_items_buttons(self):

async def get_items(self, itype=""):
if itype:
self.item_type == itype
self.item_type = itype
elif self.list_status == "gdu":
self.item_type == "folders"
self.item_type = "folders"
try:
files = self.get_files_by_folder_id(self.id, self.item_type)
if self.listener.is_cancelled:
Expand Down
4 changes: 2 additions & 2 deletions bot/helper/mirror_leech_utils/rclone_utils/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ async def get_path_buttons(self):

async def get_path(self, itype=""):
if itype:
self.item_type == itype
self.item_type = itype
elif self.list_status == "rcu":
self.item_type == "--dirs-only"
self.item_type = "--dirs-only"
cmd = [
"xone",
"lsjson",
Expand Down
4 changes: 0 additions & 4 deletions bot/helper/telegram_helper/message_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,11 @@ async def update_status_message(sid, force=False):
page_no = status_dict[sid]["page_no"]
status = status_dict[sid]["status"]
is_user = status_dict[sid]["is_user"]
page_step = status_dict[sid]["page_step"]
text, buttons = await get_readable_message(
sid,
is_user,
page_no,
status,
page_step,
)
if text is None:
del status_dict[sid]
Expand Down Expand Up @@ -322,13 +320,11 @@ async def send_status_message(msg, user_id=0):
if sid in list(status_dict.keys()):
page_no = status_dict[sid]["page_no"]
status = status_dict[sid]["status"]
page_step = status_dict[sid]["page_step"]
text, buttons = await get_readable_message(
sid,
is_user,
page_no,
status,
page_step,
)
if text is None:
del status_dict[sid]
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ line-length = 85
target-version = "py310"

[lint.mccabe]
max-complexity = 50
max-complexity = 100

[lint]
select = [
Expand Down

0 comments on commit 38d55bf

Please sign in to comment.