lemontree210 · GitHub

added 2 commits

October 16, 2022 15:52
closes #3185
add 3 keyword-only arguments to pass caption
to entire media group
before that a caption for the group had to be
manually added to the 1st media item in the group

@Bibo-Joshi

"group_caption", "group_caption_parse_mode",
and "group_caption_entities" are not part of API,
so exclude them from check of arguments matching API

Bibo-Joshi

- replace "images" with "media"
- check not only .caption but also .caption_entities
and .parse_mode of individual media items
we should try to copy as little as possible:
if none of the `group_*` parameters was passed,
we don't need copying.
Otherwise, we only need to copy (the list and)
the first media item rather than all of them
rename to match arguments of functions that handle
individual media:
- group_caption -> caption
- group_caption_parse_mode -> parse_mode
- group_caption_entities -> caption_entities

Bibo-Joshi

make sure the original media group is intact

Bibo-Joshi

check that the error is raised if user passes
media that only have `parse_mode` or
`caption_entities`
Check if the user explicitly set parse_mode
for the InputMedia* object.
Even if it is set to None, ValueError must be
raised.
add fixture for a media group without individual
captions rather than taking `media_group` fixtures
and setting attributes manually
this fixture can be used later when checking
defaults
* make `parse_mode` default to DEFAULT_NONE
in `Bot` and shortcut methods in classes
* exclude `parse_mode` from check in conftest.py
* add tests for handling of default values
to allow multiple calls with same media group,
I need to copy not only the first item
(that gets the caption) but all items because
otherwise bot with Defaults will assign its
default parse mode to every item,
which will cause ValueError upon subsequent calls
unless there are other things to be fixed,
this should be the commit that closes #3185

Bibo-Joshi

Bibo-Joshi

also remove `timeout` as a remnant from v13

Closed

`_bot.py` had two imports (import copy and from copy import copy)
leave first import and replace `copy()` with `copy.copy()`
in code
Closes #3185
Refactoring becomes possible since #3305 was fixed.
Refactoring is based on ideas in commit
 c38801f 

Bibo-Joshi

@Bibo-Joshi

@lemontree210

Read the original on github.com ↗