-
-
Notifications
You must be signed in to change notification settings - Fork 563
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 datetime.utcnow + datetime.utcfromtimestamp #1809
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1809 +/- ##
==========================================
- Coverage 80.82% 80.81% -0.02%
==========================================
Files 192 192
Lines 18541 18541
Branches 4014 4014
==========================================
- Hits 14985 14983 -2
- Misses 3278 3280 +2
Partials 278 278
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
miio/miioprotocol.py
Outdated
@@ -48,7 +48,7 @@ def __init__( | |||
|
|||
self._discovered = False | |||
# these come from the device, but we initialize them here to make mypy happy | |||
self._device_ts: datetime = datetime.utcnow() | |||
self._device_ts: datetime = datetime.now(tz=timezone.utc).replace(tzinfo=None) |
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.
Thanks for the PR, @cdce8p! I'm wondering if it's necessary to have replace()
calls at all? Alas, I'm not going to have access to any test devices until next month, so I cannot really test this myself.
The CI failures are irrelevant to this PR, so they are not blockers to get this merged.
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 can't test it myself either, unfortunately.
However, I believe you might be correct here. The call in _valid_cache
is covered by the test suite. As for the protocol: AFAICT the conversion happens inside the TimeAdapter
. obj.timetuple()
strips the timezone anyway and for the decode
we might as well leave the tz
in place.
@rytilahti Gentle ping. Anything left todo here for me? |
@cdce8p thanks for the ping and sorry for the delay. I think it's good to go, but I haven't been still able to test it on any real devices. But well, we can always revert it if needed, so I just updated on top of the current master in hopes it fixes the CI issues and I'll merge this when the checks pass. |
FYI the windows error seems to be a poetry issue. Downgrading to |
Starting with Python 3.12,
datetime.utcnow
anddatetime.utcfromtimestamp
will be deprecated.https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcnow
https://docs.python.org/3.12/library/datetime.html#datetime.datetime.utcfromtimestamp