Remove path to string convertion (#1612)

* Remove path to string conversion

* docs: changelog added
This commit is contained in:
Oleg A. 2025-01-04 11:37:26 +03:00 committed by GitHub
parent b376949647
commit 44bd8fe103
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 10 deletions

View file

@ -391,7 +391,7 @@ class Bot:
@classmethod
async def __aiofiles_reader(
cls, file: str, chunk_size: int = 65536
cls, file: Union[str, pathlib.Path], chunk_size: int = 65536
) -> AsyncGenerator[bytes, None]:
async with aiofiles.open(file, "rb") as f:
while chunk := await f.read(chunk_size):
@ -399,7 +399,7 @@ class Bot:
async def download_file(
self,
file_path: str,
file_path: Union[str, pathlib.Path],
destination: Optional[Union[BinaryIO, pathlib.Path, str]] = None,
timeout: int = 30,
chunk_size: int = 65536,
@ -423,7 +423,7 @@ class Bot:
close_stream = False
if self.session.api.is_local:
stream = self.__aiofiles_reader(
str(self.session.api.wrap_local_file.to_local(file_path)), chunk_size=chunk_size
self.session.api.wrap_local_file.to_local(file_path), chunk_size=chunk_size
)
close_stream = True
else:

View file

@ -67,7 +67,7 @@ class TelegramAPIServer:
"""
return self.base.format(token=token, method=method)
def file_url(self, token: str, path: str) -> str:
def file_url(self, token: str, path: Union[str, Path]) -> str:
"""
Generate URL for downloading files