Fix ZoneInfo handling in datetime constructor - #136
Open
binggao1230 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Vincent Gao <gaobing1230@gmail.com>
1 task
Collaborator
|
@gaoflow, thank you for contributing. The new tests are currently failing on Windows because the system time zone data is not installed by default on Windows. I opened #138 to address this. After that PR is merged, your updated tests should pass and I will merge this PR. |
1 task
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this Pull Request accomplish?
Fixes #126.
This updates
hightime.datetime.__new__to treat anydatetime.tzinfoinstance as the positionaltzinfoargument that can be passed internally bydatetime.datetime, instead of only acceptingdatetime.timezone. It also adds regression coverage forZoneInfo("America/Chicago")through bothnow(tz=...)andastimezone(...).Why should this Pull Request be merged?
ZoneInfoand othertzinfosubclasses are valid timezone values. Before this change, hightime interpreted them as itsfemtosecondargument and raisedTypeError, which brokenow(tz=ZoneInfo(...))andastimezone(...).What testing has been done?
.venv/bin/python -m pytest tests/test_datetime.py::test_datetime_now_with_zoneinfo tests/test_datetime.py::test_datetime_astimezone_with_zoneinfo -q.venv/bin/python -m pytest tests/test_datetime.py -q.venv/bin/python -m pytest -q.venv/bin/ni-python-styleguide lint.venv/bin/mypy.venv/bin/bandit -c pyproject.toml -r hightimeZoneInfo("America/Chicago")reproduction fornow(tz=...)andastimezone(...)