Remove custom enum parsing

Python enums can already be parsed out-of-the-box.
This commit is contained in:
Lonami Exo
2022-01-16 12:06:42 +01:00
parent 8c9ee3f731
commit a95393648f
4 changed files with 20 additions and 42 deletions

View File

@@ -210,7 +210,7 @@ async def download_profile_photo(
photo = entity.photo
if isinstance(photo, (_tl.UserProfilePhoto, _tl.ChatPhoto)):
thumb = enums.Size.ORIGINAL if thumb == () else enums.parse_photo_size(thumb)
thumb = enums.Size.ORIGINAL if thumb == () else enums.Size(thumb)
dc_id = photo.dc_id
loc = _tl.InputPeerPhotoFileLocation(
@@ -494,11 +494,11 @@ def _get_thumb(thumbs, thumb):
if isinstance(thumb, tlobject.TLObject):
return thumb
thumb = enums.parse_photo_size(thumb)
thumb = enums.Size(thumb)
return min(
thumbs,
default=None,
key=lambda t: abs(thumb - enums.parse_photo_size(t.type))
key=lambda t: abs(thumb - enums.Size(t.type))
)
def _download_cached_photo_size(self: 'TelegramClient', size, file):