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.
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
Replace dateutil.tz with ZoneInfo and tzlocal for better cross-platform compatibility. #40
Replace dateutil.tz with ZoneInfo and tzlocal for better cross-platform compatibility. #40
Changes from 4 commits
0dfdd1a
172a9e0
8d05f3c
93c2e8f
f79c492
45c0f2b
081a5de
2b79bff
151198f
b925550
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.
btw, according to the document, this lib needs Python >= 3.8. We need to support Python3.7.
PyPI: https://pypi.org/project/tzlocal/
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.
Let's drop it to 5.1 then. That seems to be the last version that supports Python 3.7.
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.
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.
from the official doc I didn't see examples w.r.t. error handling. But from the implementation details it seems like it could raise an exception or return None (according to their comments). Shall we add a try block to catch any exceptions?
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 agree. In fact when I was looking for a Python 3.7 compatible version of the lib, I found this from their docs:
https://pypi.org/project/tzlocal/5.1/#:~:text=tzlocal%204.0%20also%20adds%20an%20official%20function%20get_localzone_name()%20to%20get%20only%20the%20timezone%20name%2C%20instead%20of%20a%20timezone%20object.%20On%20unix%2C%20it%20can%20raise%20an%20error%20if%20you%20don%E2%80%99t%20have%20a%20timezone%20name%20configured%2C%20where%20get_localzone()%20will%20succeed%2C%20so%20only%20use%20that%20if%20you%20need%20the%20timezone%20name.
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.
The class
ZoneInfo
is an implementation oftzinfo
abstracted class, shall we narrow down the type ofself.timezone
toZoneInfo
instead?This means we should also update the type annotation in
Log._decode