Skip to content

Commit 6c2f4b6

Browse files
committed
perf: replace synchronous Path with AsyncPath for file operations
1 parent 37e4979 commit 6c2f4b6

File tree

7 files changed

+263
-158
lines changed

7 files changed

+263
-158
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ repos:
2020
pass_filenames: false
2121

2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.13.0
23+
rev: v0.13.3
2424
hooks:
2525
- id: ruff-check
26-
args: [--fix]
26+
args: [--fix, --preview]
2727
- id: ruff-format

docs/source/modules/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ When you see a command in the documentation, it may have one or more arguments t
3333
3434
- `()`: Required argument.
3535
- `(user)`: Required (user ID or username), but you can also reply to any user's message as an alternative.
36-
- `(group)`: Required (group ID or username).
3736
- `(? )`: Optional argument.
3837
```
3938

src/korone/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025 Hitalo M. <https://github.com/HitaloM>
33

4-
__version__ = "2025.09.15"
4+
__version__ = "2025.10.03"

src/korone/modules/stickers/handlers/kang.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from pathlib import Path
55

6+
from anyio import Path as AsyncPath
67
from hairydogm.keyboard import InlineKeyboardBuilder
78
from hydrogram import Client
89
from hydrogram.types import Message
@@ -61,7 +62,7 @@ async def kang_command(client: Client, message: Message) -> None:
6162
return
6263

6364
if media_type == "video" and not await check_video(sent_message, file_path): # type: ignore
64-
Path(file_path).unlink(missing_ok=True) # type: ignore
65+
await AsyncPath(file_path).unlink(missing_ok=True) # type: ignore
6566
return
6667

6768
pack_num = await get_or_create_pack(user.id, media_type)
@@ -106,5 +107,5 @@ async def kang_command(client: Client, message: Message) -> None:
106107
reply_markup=keyboard.as_markup(),
107108
)
108109

109-
Path(file_path).unlink(missing_ok=True) # type: ignore
110-
Path(resized_file).unlink(missing_ok=True)
110+
await AsyncPath(file_path).unlink(missing_ok=True) # type: ignore
111+
await AsyncPath(resized_file).unlink(missing_ok=True)

src/korone/modules/stickers/utils/medias.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# Copyright (c) 2025 Hitalo M. <https://github.com/HitaloM>
33

44
import asyncio
5-
from pathlib import Path
65

6+
from anyio import Path as AsyncPath
77
from hydrogram.types import Message
88

99
from korone.utils.i18n import gettext as _
@@ -72,7 +72,7 @@ async def check_video(message: Message, file_path: str) -> bool:
7272
await message.reply(_("Error parsing video information: {error}").format(error=str(e)))
7373
return False
7474

75-
size = Path(file_path).stat().st_size
75+
size = (await AsyncPath(file_path).stat()).st_size
7676

7777
if duration > 3:
7878
await message.edit(

src/korone/utils/logging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import logging
55
import logging.config
6-
import logging.handlers
76
import sys
87
from pathlib import Path
98
from typing import Any

uv.lock

Lines changed: 254 additions & 148 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)