diff --git a/src/aiogram_dialog/api/entities/media.py b/src/aiogram_dialog/api/entities/media.py index b8beb98b..21ae9fa6 100644 --- a/src/aiogram_dialog/api/entities/media.py +++ b/src/aiogram_dialog/api/entities/media.py @@ -1,5 +1,6 @@ from dataclasses import dataclass -from typing import Optional +from pathlib import Path +from typing import Optional, Union from aiogram.types import ContentType @@ -22,7 +23,7 @@ def __init__( self, type: ContentType, url: Optional[str] = None, - path: Optional[str] = None, + path: Union[str, Path, None] = None, file_id: Optional[MediaId] = None, use_pipe: bool = False, **kwargs, diff --git a/src/aiogram_dialog/widgets/media/static.py b/src/aiogram_dialog/widgets/media/static.py index ecc48779..43f1af7d 100644 --- a/src/aiogram_dialog/widgets/media/static.py +++ b/src/aiogram_dialog/widgets/media/static.py @@ -1,3 +1,4 @@ +from pathlib import Path from typing import Optional, Union from aiogram.types import ContentType @@ -13,7 +14,7 @@ class StaticMedia(Media): def __init__( self, *, - path: Union[Text, str, None] = None, + path: Union[Text, str, Path, None] = None, url: Union[Text, str, None] = None, type: ContentType = ContentType.PHOTO, use_pipe: bool = False, @@ -24,7 +25,9 @@ def __init__( if not (url or path): raise ValueError("Neither url nor path are provided") self.type = type - if isinstance(path, str): + if isinstance(path, Path): + path = Const(str(path)) + elif isinstance(path, str): path = Const(path) self.path = path if isinstance(url, str):