You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix typing: Replace any (the function) with typing.Any
Remove OrderedDict: for newer Python (>=3.7) versions the insertion order into dicts is already kept
Move default arguments for hourly_start and hourly_end into the function body. Otherwise they are executed when the the class is initialized. I.e. those arguments would stay the same for new method calls.
Replace datetime.utcnow with the timezone aware datetime.now(tz=UTC). utcnow will be deprecated with Python 3.12.
I wasn't sure about the + "Z" which you added manually to the iso datetime. Could you check which format the API expects? datetime.isoformat would return YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM.
Passing a date in that format (I used 2023-09-14T16:09:38.522987+00:00) results in a 400 from the API. Passing the same date in the previous format (2023-09-14T16:09:38.522987Z) works fine. The documentation never explicitly mentions a date format to use (the scalar type is just date-time and there is no description of this type anywhere), but the responses all use UTC dates in the format YYYY-MM-DDTHH:MM:SSZ.
Passing a date in that format (I used 2023-09-14T16:09:38.522987+00:00) results in a 400 from the API. Passing the same date in the previous format (2023-09-14T16:09:38.522987Z) works fine. The documentation never explicitly mentions a date format to use (the scalar type is just date-time and there is no description of this type anywhere), but the responses all use UTC dates in the format YYYY-MM-DDTHH:MM:SSZ.
Added some logic to convert the datetime arguments to UTC (if they aren't already) and to remove the timezone afterwards. Note that it will only convert to UTC if the datetime was passed with a timezone, otherwise it would assume UTC. Does this make sense?
Great, thanks! I'm not too familiar with Python and its ecosystem/idiosyncrasies so I appreciate you catching and fixing these.
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
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.
any(the function) withtyping.AnyOrderedDict: for newer Python (>=3.7) versions the insertion order into dicts is already kepthourly_startandhourly_endinto the function body. Otherwise they are executed when the the class is initialized. I.e. those arguments would stay the same for new method calls.datetime.utcnowwith the timezone awaredatetime.now(tz=UTC).utcnowwill be deprecated with Python 3.12.I wasn't sure about the
+ "Z"which you added manually to the iso datetime. Could you check which format the API expects?datetime.isoformatwould returnYYYY-MM-DDTHH:MM:SS.ffffff+HH:MM.https://docs.python.org/3/library/datetime.html#datetime.datetime.isoformat