Skip to content

fix: replace deprecated utcfromtimestamp in google-auth-oauthlib#16732

Merged
chalmerlowe merged 1 commit intomainfrom
fix-deprecated-utcfromtimestamp-232508796818525143
Apr 21, 2026
Merged

fix: replace deprecated utcfromtimestamp in google-auth-oauthlib#16732
chalmerlowe merged 1 commit intomainfrom
fix-deprecated-utcfromtimestamp-232508796818525143

Conversation

@chalmerlowe
Copy link
Copy Markdown
Contributor

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 started by @chalmerlowe

Replaces deprecated `datetime.datetime.utcfromtimestamp()` with `datetime.datetime.fromtimestamp(timestamp, datetime.timezone.utc).replace(tzinfo=None)` in `google-auth-oauthlib`. This ensures that a naive datetime is returned, maintaining backwards compatibility, and addresses issue #15433.

Co-authored-by: chalmerlowe <7291104+chalmerlowe@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chalmerlowe chalmerlowe requested review from a team as code owners April 20, 2026 17:51
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the credentials_from_session function in helpers.py across the codebase to replace the deprecated datetime.datetime.utcfromtimestamp method. The new implementation uses datetime.datetime.fromtimestamp with datetime.timezone.utc and strips the timezone information to maintain the existing behavior of using naive datetime objects. I have no feedback to provide as there were no review comments.

@chalmerlowe chalmerlowe self-assigned this Apr 20, 2026
@chalmerlowe chalmerlowe added the automerge Merge the pull request once unit tests and other checks pass. label Apr 20, 2026
@chalmerlowe chalmerlowe merged commit e1c5af7 into main Apr 21, 2026
30 checks passed
@chalmerlowe chalmerlowe deleted the fix-deprecated-utcfromtimestamp-232508796818525143 branch April 21, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Merge the pull request once unit tests and other checks pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeprecationWarning: datetime.datetime.utcfromtimestamp()

2 participants