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.
clean pending update based on Timedelta or datetime #1987
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clean pending update based on Timedelta or datetime #1987
Changes from all commits
d9988e2
deb2515
d7254b1
158419d
bc5d964
b5db0c6
62015f4
07e22b1
01cf389
766cbe6
663aece
684280f
f766b01
1541d64
4804b8b
21e0226
cafb188
531b484
ce35971
33410d3
bd21699
99dd377
cb7bb3b
6c44b67
51953a6
e3f46b8
73adbdd
907e092
c887ac3
eae79ec
30e854f
091b7a9
72098b7
5f60741
2378587
233ba3c
cd7afca
2c8990e
641e1e7
5b6f522
60dad8e
5bf813c
cac4bf4
030b9ad
d3479c0
afe7b24
08a4717
0040c88
97f3197
82f8cee
92346a5
9f5a8ce
1787202
0c4208c
2043335
e4140d9
0e96ed5
d06ecf9
534ec26
fb082a7
7dce85d
e1144a9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the second check good for? If the datetime is aware it shouldn't matter what the UTC offset is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per PY 3.6.10 documentation (scroll down just a little to the datetime.timezone section the requirement to be 'aware' is to have both conditions. If UTC offset is
None
datetime is naive.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PY 3.8.3 documentation even has dedicated a paragraph on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about changing it to
if clean.tzinfo.utcoffset(clean) is None:
but since the documentation is so specific on both requirements I don't think it's a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't check
utcoffset
in other places, too… If people set non-working stuff astzinfo
, they must expect to get errors. Also the refactoring ofJobQueue
will make people usepytz
with PTB anyway, so they might as well use it hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be sure that the updates are always ordered? I just don't know tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 assumption is the mother of f..... i got a sequential list every time i ran my tests (and a ran a lot of m... mumbling something about dates and time)
I'll have look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_updates()
but don't see orderingde_json
but don't see orderingNote that the clean as bool part also assumes an ordered by update_id list.
we could do
updates.sort(key=lambda x: x.update_id, reverse=True)
maybe even better to put this in
get_updates()
before it returns the listThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mh … Trusting TG to send updates with incremental
update_id
is okay. They implicity guarantee that byTrusting that the date necessarily increasing with the
update_id
is another thing. I don't see, why it shouldn't, but still … for the moment, just assume it is