Refactor profile photo types to use InputProfilePhotoType enums instead of hardcoded literals

This commit is contained in:
JRoot Junior 2025-07-04 03:16:12 +03:00
parent a75a5a5fdc
commit 5066e5e82f
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
3 changed files with 5 additions and 5 deletions

View file

@ -5,7 +5,7 @@ description: |
Source: https://core.telegram.org/bots/api#inputprofilephoto
multi_parse:
attribute: type
regexp: "must be '([a-z_]+)'"
regexp: "must be *([a-z_]+)*"
entities:
- InputProfilePhotoStatic
- InputProfilePhotoAnimated

View file

@ -15,7 +15,7 @@ class InputProfilePhotoAnimated(InputProfilePhoto):
Source: https://core.telegram.org/bots/api#inputprofilephotoanimated
"""
type: Literal["animated"] = "animated"
type: Literal[InputProfilePhotoType.ANIMATED] = InputProfilePhotoType.ANIMATED
"""Type of the profile photo, must be *animated*"""
animation: InputFileUnion
"""The animated profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the photo was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
@ -29,7 +29,7 @@ class InputProfilePhotoAnimated(InputProfilePhoto):
def __init__(
__pydantic__self__,
*,
type: Literal["animated"] = "animated",
type: Literal[InputProfilePhotoType.ANIMATED] = InputProfilePhotoType.ANIMATED,
animation: InputFileUnion,
main_frame_timestamp: Optional[float] = None,
**__pydantic_kwargs: Any,

View file

@ -15,7 +15,7 @@ class InputProfilePhotoStatic(InputProfilePhoto):
Source: https://core.telegram.org/bots/api#inputprofilephotostatic
"""
type: Literal["static"] = "static"
type: Literal[InputProfilePhotoType.STATIC] = InputProfilePhotoType.STATIC
"""Type of the profile photo, must be *static*"""
photo: InputFileUnion
"""The static profile photo. Profile photos can't be reused and can only be uploaded as a new file, so you can pass 'attach://<file_attach_name>' if the photo was uploaded using multipart/form-data under <file_attach_name>. :ref:`More information on Sending Files » <sending-files>`"""
@ -27,7 +27,7 @@ class InputProfilePhotoStatic(InputProfilePhoto):
def __init__(
__pydantic__self__,
*,
type: Literal["static"] = "static",
type: Literal[InputProfilePhotoType.STATIC] = InputProfilePhotoType.STATIC,
photo: InputFileUnion,
**__pydantic_kwargs: Any,
) -> None: