Make datetime objects timezone-aware (#2565)

Comparing timestamps returned by the API with naive datetime objects (without timezone information) will raise an error. Add `tzinfo=datetime.timezone.utc` to your datetime instance.

Co-authored-by: John T. Wodder II <git@varonathe.org>
This commit is contained in:
Enrico Minack
2023-06-28 21:47:48 +02:00
committed by GitHub
co-authored by John T. Wodder II
parent 99155806ed
commit 0177f7c513
67 changed files with 668 additions and 456 deletions
+3 -5
View File
@@ -47,9 +47,9 @@
# #
################################################################################
import datetime
import pickle
import warnings
from datetime import datetime
from typing import List
import urllib3
@@ -440,12 +440,10 @@ class Github:
def get_gists(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /gists/public <https://docs.github.com/en/rest/reference/gists>`_
:param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ
:param since: datetime format YYYY-MM-DDTHH:MM:SSZ
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist`
"""
assert since is github.GithubObject.NotSet or isinstance(
since, datetime.datetime
), since
assert since is github.GithubObject.NotSet or isinstance(since, datetime), since
url_parameters = dict()
if since is not github.GithubObject.NotSet:
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")