Skip to content

fix: update deprecated utcnow, utcfromtimestamp #2286

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

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion googleapiclient/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
from googleapiclient import errors

# The unix time epoch starts at midnight 1970.
EPOCH = datetime.datetime.utcfromtimestamp(0)
EPOCH = datetime.datetime(1970, 1, 1)

# Map the names of the parameters in the JSON channel description to
# the parameter names we use in the Channel class.
Expand Down
2 changes: 1 addition & 1 deletion googleapiclient/discovery_cache/file_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
LOGGER = logging.getLogger(__name__)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**
**


FILENAME = "google-api-python-client-discovery-doc.cache"
EPOCH = datetime.datetime.utcfromtimestamp(0)
EPOCH = datetime.datetime(1970, 1, 1)


def _to_timestamp(date):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,7 @@ def _dummy_token(self):
client_id = "some_client_id"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client_secret = "cOuDdkfjxxnv+"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
client_secret = "cOuDdkfjxxnv+"
client_secret = "cOuDdkfjxxnv+"``

refresh_token = "1/0/a.df219fjls0"
token_expiry = datetime.datetime.utcnow()
token_expiry = datetime.datetime.now(datetime.timezone.utc)
user_agent = "refresh_checker/1.0"
return OAuth2Credentials(
access_token,
Expand Down