Types init alignment - #2622
Conversation
__init__ parameters type hints aligned with API.
|
@coder2020official It was not so easy... Most work was automated, all found issues were processed manually. |
There was a problem hiding this comment.
🟡 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 acrosstelebot/types.pyto reflect API field types more precisely. - Adjusted
InputMedia*handling to useattach://...references for additional file-like fields (e.g., thumbnails/covers/photos). - Extended
convert_input_media_array()intelebot/apihelper.pyto 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.
There was a problem hiding this comment.
🟡 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
|
@coder2020official Go? 🙈 |
|
looks good on a quick glance, but I'd need 2 days to check this thoroughly and hopefully even test it out |
❤️ |
There was a problem hiding this comment.
For media, this will return attach:// but the files will not be sent to the API
|
@Badiboy it seems like uploads for InputRichBlockAnimation, InputRichBlockAudio, InputRichBlockPhoto, InputRichBlockVideo, InputRichBlockVoiceNote will not work +InputRichMessageMedia above |
|
Apihelper would also need altering, for functions like send_rich_message, send_rich_message_draft, and edit_message_text |
There was a problem hiding this comment.
Files are dropped here too. needs to call media.convert_input_media?
|
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.
|
|
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
|
|
@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. |
|
@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: 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... |
|
Yeah sure |
Description
Align classes initialization with API.