Skip to content

Types init alignment - #2622

Merged
Badiboy merged 4 commits into
eternnoir:masterfrom
Badiboy:master
Aug 28, 2026
Merged

Types init alignment#2622
Badiboy merged 4 commits into
eternnoir:masterfrom
Badiboy:master

Conversation

@Badiboy

@Badiboy Badiboy commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Description

Align classes initialization with API.

__init__ parameters type hints aligned with API.
@Badiboy
Badiboy marked this pull request as draft August 22, 2026 12:57
@Badiboy
Badiboy marked this pull request as ready for review August 22, 2026 22:44
@Badiboy
Badiboy requested review from coder2020official and a lite review from Copilot August 22, 2026 22:44
@Badiboy

Badiboy commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator Author

@coder2020official It was not so easy... Most work was automated, all found issues were processed manually.
I did my best to validate results, but I'm dead to the end of the day, so there may be misses.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The current attachment serialization changes break multipart uploads for thumbnails/covers/live-photo photos in media arrays and also allow invalid photo=None in InputMediaLivePhoto, causing malformed requests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates telebot model initializers and related serialization to better align class construction/type hints with the Telegram Bot API, particularly around InputMedia* and several API object classes.

Changes:

  • Added/updated many __init__ type annotations across telebot/types.py to reflect API field types more precisely.
  • Adjusted InputMedia* handling to use attach://... references for additional file-like fields (e.g., thumbnails/covers/photos).
  • Extended convert_input_media_array() in telebot/apihelper.py to handle more media-related file fields.
File summaries
File Description
telebot/types.py Adds/adjusts type hints and attachment reference logic for multiple API types, including InputMedia*.
telebot/apihelper.py Updates convert_input_media_array() to try to include additional uploadable fields (cover/photo).
Review details
  • Files reviewed: 1/2 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread telebot/apihelper.py Outdated
Comment thread telebot/types.py
Comment thread telebot/types.py
Comment thread telebot/types.py
Comment thread telebot/types.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are confirmed typing/API inconsistencies in updated constructors and a concrete robustness issue in file collection (missing InputFile validation) that can create invalid multipart payloads.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread telebot/apihelper.py
Comment thread telebot/asyncio_helper.py
@Badiboy

Badiboy commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

@coder2020official Go? 🙈

@coder2020official

Copy link
Copy Markdown
Collaborator

looks good on a quick glance, but I'd need 2 days to check this thoroughly and hopefully even test it out

@Badiboy

Badiboy commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator Author

looks good on a quick glance, but I'd need 2 days to check this thoroughly and hopefully even test it out

❤️

Comment thread telebot/types.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For media, this will return attach:// but the files will not be sent to the API

@coder2020official

coder2020official commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

@Badiboy it seems like uploads for InputRichBlockAnimation, InputRichBlockAudio, InputRichBlockPhoto, InputRichBlockVideo, InputRichBlockVoiceNote will not work

+InputRichMessageMedia above

@coder2020official

Copy link
Copy Markdown
Collaborator

Apihelper would also need altering, for functions like send_rich_message, send_rich_message_draft, and edit_message_text

Comment thread telebot/types.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Files are dropped here too. needs to call media.convert_input_media?

@Badiboy

Badiboy commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Yeeeeeep, looks like Rich is absolutely out of uploads. I need to verify what's there attentively. I did not got into new Rich magic deep yet.

@Badiboy it seems like uploads for InputRichBlockAnimation, InputRichBlockAudio, InputRichBlockPhoto, InputRichBlockVideo, InputRichBlockVoiceNote will not work

@coder2020official

Copy link
Copy Markdown
Collaborator

While reviewing, I also found out that:

-- replace_sticker_in_set should use convert_input_sticker to upload stickers similar to add_sticker_to_set
-- checklist in send_checklist needs .to_dict()

  • both in apihelper & asyncio_helper files

Comment thread telebot/types.py
@coder2020official

Copy link
Copy Markdown
Collaborator

@Badiboy after you're done with this, would you be able to implement the bot api update?

@Badiboy

Badiboy commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@Badiboy after you're done with this, would you be able to implement the bot api update?

I'm in parallel working on it trying to apply current results to resolve update. Have some progress, but it looks a bit fra from production. I need some time for this, after that will report.

@Badiboy

Badiboy commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@coder2020official I tried to get with your review but failed...

Too much changes, I cannot handle all of it.

I propose to extract your points:
1.
InputRichBlockAnimation, InputRichBlockAudio, InputRichBlockPhoto, InputRichBlockVideo, InputRichBlockVoiceNote
2.

replace_sticker_in_set should use convert_input_sticker to upload stickers similar to add_sticker_to_set
checklist in send_checklist needs .to_dict()
both in apihelper & asyncio_helper files

To a separate PR. And do it later due to lot of changes hanged on my side.

If you agree, I'll note them as Issue for later processing. Then Merge this and will open new PR...

@coder2020official

Copy link
Copy Markdown
Collaborator

Yeah sure

@Badiboy
Badiboy merged commit 177cb25 into eternnoir:master Aug 28, 2026
6 checks passed
@Badiboy Badiboy mentioned this pull request Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants