Skip to content

Extend Support for Convenience Types in Bot Methods #4580

@Bibo-Joshi

Description

@Bibo-Joshi

What kind of feature are you missing? Where do you notice a shortcoming of PTB?

In test_official we currently allow convenience input types only for send_* methods:

# 2) HANDLING OTHER TYPES:
# Special case for send_* methods where we accept more types than the official API:
elif ptb_param.name in PTCE.ADDITIONAL_TYPES and obj.__name__.startswith("send"):
log("Checking that `%s` has an additional argument!\n", ptb_param.name)
mapped_type = mapped_type | PTCE.ADDITIONAL_TYPES[ptb_param.name]

ADDITIONAL_TYPES = {
"photo": PhotoSize,
"video": Video,
"video_note": VideoNote,
"audio": Audio,
"document": Document,
"animation": Animation,
"voice": Voice,
"sticker": Sticker,
}

Removing the obj.__name__.startswith("send") reveals that there are a few more parameters that could use convenience types.

Describe the solution you'd like

  • Set up the "additional types" excetpions in test_official such that they can either be defined globally or per method, remove the obj.__name__ check
  • add support for convenience types where possible

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ⚙️ bot-apiaffected functionality: bot-api⚙️ testsaffected functionality: tests⚙️ type-hintingaffected functionality: type-hinting🔌 enhancementpr description: enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions