FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

refactor: add enum constants by lemontree210 · Pull Request #3351 · python-telegram-bot/python-telegram-bot · GitHub

refactor: add enum constants - #3351

Merged
Bibo-Joshi merged 50 commits into
masterfrom
enums-instead-of-literals-3107
Nov 22, 2022
Merged

refactor: add enum constants#3351
Bibo-Joshi merged 50 commits into
masterfrom
enums-instead-of-literals-3107

Conversation

lemontree210 commented Nov 8, 2022
edited
Loading

Copy link
Copy Markdown
Member

Addresses #3107. This PR replaces #3336 that was a PR from my own fork. Instead, now it's a PR within the repository.

  • Among others, be sure to add limits for:
    • set_chat_admin_custom_title
    • set_chat_title
    • set_chat_description
    • create_new_sticker_set name, title
  • change docstrings in existing classes in constants.py:
    • add :paramref:s
  • add .. versionadded:: 20.0 to every added constant in "target" classes (e.g. like it's done for class constants in InlineQuery)

lemontree210 added the ⚙️ documentation affected functionality: documentation label Nov 8, 2022
as suggested in review for PR #3336,
but in singular (rather than `...Limits`)
to conform with review for #3343

Copy link
Copy Markdown
Member Author

This is not part of the code I'm changing, but I was just creating a class with limits for ReplyKeyboardMarkup and noticed this. I don't think that InlineKeyboardMarkupLimit here has actually something to do with limits for any params in Bot.send_message, contrary to what's stated in the docstring.

Copy link
Copy Markdown
Member Author

I don't think that InlineKeyboardMarkupLimit here has actually something to do with limits for any params in Bot.send_message.

BTW, class InlineKeyboardMarkupLimit in constants.py doesn't seem to be used anywhere, not even in InlineKeyboardMarkup docstring.

This comment was marked as resolved.

* add links to/from `InlineQueryResultLocation` and `InputLocationMessageContent`
that were not added in previous commits

* note that `Location` class does not have
limits specified for `live_period` and
`proximity_alert_radius` but `InlineQueryResultLocation`
and `InputLocationMessageContent` do

lemontree210 left a comment
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I remember that adding class constants to Bot is not optimal, but shouldn't I fully implement the approach laid out in description for #3107 in Dice? Which would mean introducing class constants for emoji and value in Dice class directly and linking them to constants.py.

+ make sure the order of constants is kept in docs

Bibo-Joshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

you're being thorough, nice! :)

Comment thread docs/source/telegram.constants.rst Outdated
Comment thread docs/source/telegram.dice.rst Outdated
Comment thread telegram/_dice.py
Comment thread telegram/_dice.py Outdated
Comment thread telegram/constants.py
note that this approach leads to similar constants
in multiple classes
reverting changes made to telegram.dice.rst
in  cbe20e6
Comment thread telegram/_bot.py
Comment thread telegram/_bot.py Outdated

Copy link
Copy Markdown
Member Author

Do you think I should also replace "emoji literals" in filters.py with links to constants?

lemontree210 mentioned this pull request Nov 20, 2022
23 tasks

lemontree210 commented Nov 20, 2022
edited
Loading

Copy link
Copy Markdown
Member Author

Saving comments by @Bibo-Joshi here:

I vote to keep ChatIniviteLinkLimit separate from a potential ChatLimit enum, since ChatIniviteLinkLimit addresses limits of the ChatInviteLink class rather than generic chat-related limits.

Putting title limits into a ChatLimit enum is okay IMO.

I also vote to keep the current Chat* enums separate from a ChatLimit enum:

  • ChatAction is mostly related to send_chat_action and has little to do with the Chat class
  • ChatID also has little to do with the Chat class
  • ChatMemberStatus is about the ChatMember class and not about limits
  • ChatType is not about limits

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as outdated.

Comment thread telegram/_dice.py
@@ -93,3 +106,45 @@ def __init__(self, value: int, emoji: str, *, api_kwargs: JSONDict = None):
"""

lemontree210 Nov 21, 2022
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This comment is about the lines above this one. I didn't add any .. versionadded to class constants that I didn't create, though I think this needs to be done. I also think that the version marking in the line immediately above this one (for BOWLING) might be wrong: a bowling emoji was added in 13.4, but the constant itself is being introduced in 20.0. So maybe all constants referring to DiceEmoji should also get the 20.0 marking.

(Since I wasn't changing those lines, I couldn't add a comment to them directly)

lemontree210 marked this pull request as ready for review November 21, 2022 16:59
lemontree210 self-assigned this Nov 21, 2022

harshil21 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This PR is very high effort and simply insane. It was excruciating for me to just review over the past few days! Well done!

harshil21 linked an issue Nov 21, 2022 that may be closed by this pull request
Bibo-Joshi merged commit c3f8fcd into master Nov 22, 2022
Bibo-Joshi deleted the enums-instead-of-literals-3107 branch November 22, 2022 10:07
github-actions Bot locked and limited conversation to collaborators Nov 29, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

⚙️ documentation affected functionality: documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Constant improvement

3 participants


Back | FazBrowse Home | New Git URL