- Notifications
You must be signed in to change notification settings - Fork5.7k
Usetimedelta
to represent time periods in classes#4750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
33 commits Select commitHold shift + click to select a range
40d354a
Setup helper functions and a common test fixture.
aelkheir5cd6507
Accept timedeltas in params of `ChatFullInfo`.
aelkheira3b340b
Add chango fragment for PR #4750
aelkheird60b9fe
Refactor `test_chatfullinfo.py` a bit.
aelkheird4d62ce
Oops, so many white spaces.
aelkheir3084d3b
Finish up `ChatFullInfo` plus some helper tweaks.
aelkheir8d48756
Modify ``docs/substitutions/global.rst``.
aelkheir8ef4ca9
Accept timedeltas in ``duration`` param of media classes.
aelkheir28af9f7
Undeprecate passing `ints` to classes' arguments.
aelkheir319dd6c
Accept timedeltas in params of `InlineQueryResult.*` classes.
aelkheird8dbe15
Accept timedeltas in other time period params.
aelkheircaa831b
Modify test_official to handle time periods as timedelta automatically.
aelkheir881a9f6
Accept timedeltas in Bot.get_updates.timeout.
aelkheir466e0b0
Elaborate chango fragment for PR.
aelkheir216b90b
Merge remote-tracking branch 'upstream/master' into feature/4575-time…
aelkheirfb9a709
Update ``timeout`` type annotation in Application, Updater methods.
aelkheir4e9f5fa
Accept timedelta in RetryAfter.
aelkheira4d4d12
Include attribute name in warning message.
aelkheir3194848
review: refactor `_utils/datetime.get_timedelta_value`.
aelkheirde83ac6
Remove temporarily time period parser introduced in #4769.
aelkheir10e716a
review: address comments
aelkheirb20f9f9
Fix precommit and update `test_request.py`.
aelkheir719e9b3
Fix a test in `test_updater.py` that hangs.
aelkheircd0fd0e
Merge remote-tracking branch 'upstream/master' into feature/4575-time…
aelkheir574b09d
Move `to_dict` logic to `_telegramobject.py`.
aelkheir2a4ed74
Merge remote-tracking branch 'upstream/master' into feature/4575-time…
aelkheireb34ae3
Add a test for `get_timedelta_value`.
aelkheir7d93eb5
Fix precommit.
aelkheiraba92df
review: address comments.
aelkheir11ac715
review: update handling of deprecation logic in telegramobject.
aelkheire9a63c2
fix typo in docstring of `TO._is_deprecated_attr`
aelkheir0ef3041
review: some other points.
aelkheir5aabf59
Mock business float period properties.
aelkheirFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletionschanges/unreleased/4750.jJBu7iAgZa96hdqcpHK96W.toml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
features = "Use `timedelta` to represent time periods in class arguments and attributes" | ||
deprecations = """In this release, we're migrating attributes of Telegram objects that represent durations/time periods from having :obj:`int` type to Python's native :class:`datetime.timedelta`. This change is opt-in for now to allow for a smooth transition phase. It will become opt-out in future releases. | ||
Set ``PTB_TIMEDELTA=true`` or ``PTB_TIMEDELTA=1`` as an environment variable to make these attributes return :obj:`datetime.timedelta` objects instead of integers. Support for :obj:`int` values is deprecated and will be removed in a future major version. | ||
Affected Attributes: | ||
- :attr:`telegram.ChatFullInfo.slow_mode_delay` and :attr:`telegram.ChatFullInfo.message_auto_delete_time` | ||
- :attr:`telegram.Animation.duration` | ||
- :attr:`telegram.Audio.duration` | ||
- :attr:`telegram.Video.duration` and :attr:`telegram.Video.start_timestamp` | ||
- :attr:`telegram.VideoNote.duration` | ||
- :attr:`telegram.Voice.duration` | ||
- :attr:`telegram.PaidMediaPreview.duration` | ||
- :attr:`telegram.VideoChatEnded.duration` | ||
- :attr:`telegram.InputMediaVideo.duration` | ||
- :attr:`telegram.InputMediaAnimation.duration` | ||
- :attr:`telegram.InputMediaAudio.duration` | ||
- :attr:`telegram.InputPaidMediaVideo.duration` | ||
- :attr:`telegram.InlineQueryResultGif.gif_duration` | ||
- :attr:`telegram.InlineQueryResultMpeg4Gif.mpeg4_duration` | ||
- :attr:`telegram.InlineQueryResultVideo.video_duration` | ||
- :attr:`telegram.InlineQueryResultAudio.audio_duration` | ||
- :attr:`telegram.InlineQueryResultVoice.voice_duration` | ||
- :attr:`telegram.InlineQueryResultLocation.live_period` | ||
- :attr:`telegram.Poll.open_period` | ||
- :attr:`telegram.Location.live_period` | ||
- :attr:`telegram.MessageAutoDeleteTimerChanged.message_auto_delete_time` | ||
- :attr:`telegram.ChatInviteLink.subscription_period` | ||
- :attr:`telegram.InputLocationMessageContent.live_period` | ||
- :attr:`telegram.error.RetryAfter.retry_after` | ||
""" | ||
internal = "Modify `test_official` to handle time periods as timedelta automatically." | ||
[[pull_requests]] | ||
uid = "4750" | ||
author_uid = "aelkheir" | ||
closes_threads = ["4575"] |
2 changes: 2 additions & 0 deletionsdocs/substitutions/global.rst
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
5 changes: 4 additions & 1 deletionexamples/rawapibot.py
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
19 changes: 14 additions & 5 deletionssrc/telegram/_bot.py
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
69 changes: 50 additions & 19 deletionssrc/telegram/_chatfullinfo.py
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
36 changes: 25 additions & 11 deletionssrc/telegram/_chatinvitelink.py
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
15 changes: 3 additions & 12 deletionssrc/telegram/_files/_inputstorycontent.py
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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.