-
Notifications
You must be signed in to change notification settings - Fork 42
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.utcfromtimestamp #404
base: master
Are you sure you want to change the base?
Conversation
caaee9f
to
7994dd2
Compare
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.
After reading PR description and the commit message it is still not obvious to me why is this change done this way. I assume that the method is deprecated for a reason. I don't understand why we basically ignore the deprecation and recreate the behavior of this method instead of using the solution from the deprecation warning.
In the commit message you wrote "either include timezone into datetime, which we
do not want, or offset datetime from utc.", but you did not explain why we do not want it.
I'm not saying the patch is wrong (it is probably good), but I need more detailed explanation - it will be useful for future readers.
cassandra/query.py
Outdated
from cassandra import ConsistencyLevel, OperationTimedOut | ||
from cassandra.util import unix_time_from_uuid1, maybe_add_timeout_to_query | ||
from cassandra.util import unix_time_from_uuid1, maybe_add_timeout_to_query, utcfromtimestamp | ||
from cassandra.encoder import Encoder | ||
import cassandra.encoder |
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 see that you added this import in this file, but did not change anything else in the file. Is the import used?
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.
removed
It is depricated and to be removed soon. Only method available out-of-box for this purpose is `datetime.fromtimestamp`. But it either include timezone into datetime which is not acceptable, or offset datetime from utc which we don't want to happen. On other hand `tz_info` in not writable on `datetime` and all API that allows you to manipulate it offsets time. So, simpliest solution would to be ship a function that calls `datetime.fromtimestamp` and then builds exactly same datetime with tz_info empty.
7994dd2
to
18e2644
Compare
Please take a look again |
It is depricated and to be removed soon.
It also makes warning to pop up:
Only method available out-of-box for this purpose is
datetime.fromtimestamp
.But it either include timezone into datetime which is not acceptable (because datetime
implementation does not allow you to compare
datetimewith
tz_infoand wihtout it) or offset
datetimefrom utc which we don't want to happen because it changes actual time. On other hand
tz_infoin not writable on
datetimeand all API that allows you to manipulate it offsets time as well. So, simpliest solution would to be ship a function that calls
datetime.fromtimestampand then builds exactly same
datetimewith
tz_info` empty.Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.