This commit is contained in:
Taras Terletskyi 2023-12-12 23:49:20 +02:00
parent 246134a007
commit 098451777e
6 changed files with 13 additions and 8 deletions

View file

@ -1,5 +1,5 @@
from bot.core.config.config import settings
__all__ = [
"settings",
'settings',
]

View file

@ -44,9 +44,9 @@ class SuccessDownloadHandler(AbstractDownloadHandler):
try:
await asyncio.gather(*coro_tasks)
finally:
await self._delete_acknowledge_message()
await self._delete_acknowledgment_message()
async def _delete_acknowledge_message(self) -> None:
async def _delete_acknowledgment_message(self) -> None:
await self._bot.delete_messages(
chat_id=self._body.from_chat_id,
message_ids=[self._body.context.ack_message_id],

View file

@ -209,7 +209,7 @@ class MediaDownloader:
def _find_downloaded_file(self, root_path: str, extension: str) -> str | None:
"""Try to find downloaded audio or thumbnail file."""
verbose_name = self._EXT_TO_NAME[extension]
for file_name in glob.glob(f"*.{extension}", root_dir=root_path):
for file_name in glob.glob(f'*.{extension}', root_dir=root_path):
self._log.info(
'Found downloaded %s: "%s" [%s]',
verbose_name,

View file

@ -7,3 +7,8 @@ line-length = 88
select = ["F", "E", "W", "I001"]
ignore = ["E501"] # Skip line length violations
src = ["app_api", "app_bot", "app_worker"]
[tool.ruff.format]
indent-style = "space"
quote-style = "single"
line-ending = "lf"

View file

@ -67,7 +67,7 @@ class BaseMedia(RealBaseModel):
def mark_as_converted(self, filepath: str) -> None:
self.converted_filepath = filepath
self.converted_filename = filepath.rsplit("/", 1)[-1]
self.converted_filename = filepath.rsplit('/', 1)[-1]
self.converted_file_size = file_size(filepath)
self.is_converted = True

View file

@ -10,13 +10,13 @@ _UNIT_SIZE_NAMES = ('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi')
_BASE = 1024.0
def format_bytes(num: int, suffix: str = "B") -> str:
def format_bytes(num: int, suffix: str = 'B') -> str:
"""Format bytes to human-readable size."""
for unit in _UNIT_SIZE_NAMES:
if abs(num) < _BASE:
return f"{num:3.1f}{unit}{suffix}"
return f'{num:3.1f}{unit}{suffix}'
num /= _BASE
return f"{num:.1f}Yi{suffix}"
return f'{num:.1f}Yi{suffix}'
class Singleton(type):