Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e1c5af7

Browse filesBrowse files
fix: replace deprecated utcfromtimestamp in google-auth-oauthlib (#16732)
This PR replaces the usage of the deprecated `datetime.datetime.utcfromtimestamp` in the `google-auth-oauthlib` package and testdata. Using `datetime.datetime.fromtimestamp(session.token["expires_at"], datetime.timezone.utc).replace(tzinfo=None)` avoids the deprecation warning in Python 3.12 while preserving backwards compatibility by returning a naive datetime object. Fixes #15433 --- *PR created automatically by Jules for task [232508796818525143](https://jules.google.com/task/232508796818525143) started by @chalmerlowe* Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: chalmerlowe <7291104+chalmerlowe@users.noreply.github.com>
1 parent a1417ae commit e1c5af7
Copy full SHA for e1c5af7

2 files changed

+6-2Lines changed: 6 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • gcp-sphinx-docfx-yaml/tests/testdata/auth/google_auth_oauthlib
    • google-auth-oauthlib/google_auth_oauthlib
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/gcp-sphinx-docfx-yaml/tests/testdata/auth/google_auth_oauthlib/helpers.py‎

Copy file name to clipboardExpand all lines: packages/gcp-sphinx-docfx-yaml/tests/testdata/auth/google_auth_oauthlib/helpers.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,7 @@ def credentials_from_session(session, client_config=None):
147147
scopes=session.scope,
148148
granted_scopes=session.token.get("scope"),
149149
)
150-
credentials.expiry = datetime.datetime.utcfromtimestamp(session.token["expires_at"])
150+
credentials.expiry = datetime.datetime.fromtimestamp(
151+
session.token["expires_at"], datetime.timezone.utc
152+
).replace(tzinfo=None)
151153
return credentials
Collapse file

‎packages/google-auth-oauthlib/google_auth_oauthlib/helpers.py‎

Copy file name to clipboardExpand all lines: packages/google-auth-oauthlib/google_auth_oauthlib/helpers.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,7 @@ def credentials_from_session(session, client_config=None):
147147
scopes=session.scope,
148148
granted_scopes=session.token.get("scope"),
149149
)
150-
credentials.expiry = datetime.datetime.utcfromtimestamp(session.token["expires_at"])
150+
credentials.expiry = datetime.datetime.fromtimestamp(
151+
session.token["expires_at"], datetime.timezone.utc
152+
).replace(tzinfo=None)
151153
return credentials

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.