Fix review issues from PR #1761

- Remove stray '-' artifact from GameHighScore docstring and butcher schema
- Fix Makefile reformat target scope inconsistency (ruff check --fix)
- Fix ButtonStyle enum source URL (#chat -> #inlinekeyboardbutton)
- Add User.get_profile_audios() shortcut method (parallel to get_profile_photos)
- Test ChatOwnerLeft with new_owner=None (edge case)
- Add VideoQuality type and Video.qualities nesting tests
- Add User.get_profile_audios() test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
latand 2026-02-09 20:51:31 +02:00
parent 8783c4922e
commit 2184e98988
9 changed files with 102 additions and 12 deletions

View file

@ -2,7 +2,7 @@ name: ButtonStyle
description: |
This object represents a button style (inline- or reply-keyboard).
Source: https://core.telegram.org/bots/api#chat
Source: https://core.telegram.org/bots/api#inlinekeyboardbutton
parse:
entity: InlineKeyboardButton
attribute: style

View file

@ -7,9 +7,9 @@
"object": {
"anchor": "gamehighscore",
"name": "GameHighScore",
"description": "This object represents one row of the high scores table for a game.\nAnd that's about all we've got for now.\nIf you've got any questions, please check out our Bot FAQ\n-",
"html_description": "<p>This object represents one row of the high scores table for a game.</p><p>And that's about all we've got for now.<br/>\nIf you've got any questions, please check out our <a href=\"/bots/faq\"><strong>Bot FAQ &#187;</strong></a><br/>\n-</p>",
"rst_description": "This object represents one row of the high scores table for a game.\nAnd that's about all we've got for now.\n\nIf you've got any questions, please check out our `https://core.telegram.org/bots/faq <https://core.telegram.org/bots/faq>`_ **Bot FAQ »**\n\n-",
"description": "This object represents one row of the high scores table for a game.\nAnd that's about all we've got for now.\nIf you've got any questions, please check out our Bot FAQ",
"html_description": "<p>This object represents one row of the high scores table for a game.</p><p>And that's about all we've got for now.<br/>\nIf you've got any questions, please check out our <a href=\"/bots/faq\"><strong>Bot FAQ &#187;</strong></a></p>",
"rst_description": "This object represents one row of the high scores table for a game.\nAnd that's about all we've got for now.\n\nIf you've got any questions, please check out our `https://core.telegram.org/bots/faq <https://core.telegram.org/bots/faq>`_ **Bot FAQ »**",
"annotations": [
{
"type": "Integer",

View file

@ -44,7 +44,7 @@ lint:
.PHONY: reformat
reformat:
uv run ruff format $(code_dir)
uv run ruff check --fix $(package_dir)
uv run ruff check --fix $(code_dir)
# =================================================================================================
# Tests

View file

@ -5,7 +5,7 @@ class ButtonStyle(str, Enum):
"""
This object represents a button style (inline- or reply-keyboard).
Source: https://core.telegram.org/bots/api#chat
Source: https://core.telegram.org/bots/api#inlinekeyboardbutton
"""
DANGER = "danger"

View file

@ -15,8 +15,6 @@ class GameHighScore(TelegramObject):
If you've got any questions, please check out our `https://core.telegram.org/bots/faq <https://core.telegram.org/bots/faq>`_ **Bot FAQ »**
-
Source: https://core.telegram.org/bots/api#gamehighscore
"""

View file

@ -7,7 +7,7 @@ from ..utils.link import create_tg_link
from .base import TelegramObject
if TYPE_CHECKING:
from ..methods import GetUserProfilePhotos
from ..methods import GetUserProfileAudios, GetUserProfilePhotos
class User(TelegramObject):
@ -146,3 +146,32 @@ class User(TelegramObject):
limit=limit,
**kwargs,
).as_(self._bot)
def get_profile_audios(
self,
offset: int | None = None,
limit: int | None = None,
**kwargs: Any,
) -> GetUserProfileAudios:
"""
Shortcut for method :class:`aiogram.methods.get_user_profile_audios.GetUserProfileAudios`
will automatically fill method attributes:
- :code:`user_id`
Use this method to get a list of profile audios for a user. Returns a :class:`aiogram.types.user_profile_audios.UserProfileAudios` object.
Source: https://core.telegram.org/bots/api#getuserprofileaudios
:param offset: Sequential number of the first audio to be returned. By default, all audios are returned.
:param limit: Limits the number of audios to be retrieved. Values between 1-100 are accepted. Defaults to 100.
:return: instance of method :class:`aiogram.methods.get_user_profile_audios.GetUserProfileAudios`
"""
from aiogram.methods import GetUserProfileAudios
return GetUserProfileAudios(
user_id=self.id,
offset=offset,
limit=limit,
**kwargs,
).as_(self._bot)

View file

@ -258,9 +258,7 @@ TEST_MESSAGE_LEFT_CHAT_MEMBER = Message(
TEST_MESSAGE_CHAT_OWNER_LEFT = Message(
message_id=42,
date=datetime.datetime.now(),
chat_owner_left=ChatOwnerLeft(
new_owner=User(id=43, is_bot=False, first_name="NewOwner"),
),
chat_owner_left=ChatOwnerLeft(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
)

View file

@ -56,3 +56,9 @@ class TestUser:
method = user.get_profile_photos(description="test")
assert method.user_id == user.id
def test_get_profile_audios(self):
user = User(id=42, is_bot=False, first_name="Test", last_name="User")
method = user.get_profile_audios(description="test")
assert method.user_id == user.id

View file

@ -0,0 +1,59 @@
from aiogram.types import Video, VideoQuality
class TestVideoQuality:
def test_instantiation(self):
vq = VideoQuality(
file_id="abc123",
file_unique_id="unique123",
width=1920,
height=1080,
codec="h264",
)
assert vq.file_id == "abc123"
assert vq.file_unique_id == "unique123"
assert vq.width == 1920
assert vq.height == 1080
assert vq.codec == "h264"
assert vq.file_size is None
def test_instantiation_with_file_size(self):
vq = VideoQuality(
file_id="abc123",
file_unique_id="unique123",
width=1920,
height=1080,
codec="h265",
file_size=1048576,
)
assert vq.file_size == 1048576
def test_video_with_qualities(self):
video = Video(
file_id="video123",
file_unique_id="unique_video123",
width=1920,
height=1080,
duration=120,
qualities=[
VideoQuality(
file_id="q1",
file_unique_id="uq1",
width=1920,
height=1080,
codec="h264",
),
VideoQuality(
file_id="q2",
file_unique_id="uq2",
width=1280,
height=720,
codec="h264",
file_size=524288,
),
],
)
assert video.qualities is not None
assert len(video.qualities) == 2
assert video.qualities[0].width == 1920
assert video.qualities[1].file_size == 524288