Skip to content
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

fix: Resolve deprecation warning by using explicit UTC timezone instead of datetime.utcnow #15

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

brouberol
Copy link
Contributor

Starting from python 3.12.0, we started seeing some deprecation warning related to use of datetime.datetime.utcnow:

  /Users/.../lib/python3.12/site-packages/fastapi_jwt/jwt.py:135: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    now = datetime.utcnow()

This PR should provide the same level of functionality without firing a deprecation warning, by implementing the suggested change.

@brouberol brouberol force-pushed the patch-1 branch 2 times, most recently from 7d74fd8 to 71e4bca Compare November 1, 2023 15:28
Copy link

codecov bot commented Nov 1, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e901cb9) 100.00% compared to head (fa4cd5f) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          154       158    +4     
=========================================
+ Hits           154       158    +4     
Files Coverage Δ
fastapi_jwt/jwt.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@k4black
Copy link
Owner

k4black commented Nov 2, 2023

Hey, @brouberol thank you for your PR!
Could you please add 3.8,3.9,3.10 backward compatibility for this changes? (please refer auto tests)
And fix codestyle with isort.

Note: I've merged main to your branch to run it on 3.12.

@brouberol brouberol force-pushed the patch-1 branch 3 times, most recently from 4d535f2 to 10625e3 Compare November 2, 2023 08:04
…ow` in py3.12

Starting from python 3.12.0, we started seeing some deprecation warning related to use of `datetime.datetime.utcnow`:

```
/Users/.../lib/python3.12/site-packages/fastapi_jwt/jwt.py:135: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
now = datetime.utcnow()
```

This PR should provide the same level of functionality without firing a deprecation warning, by implementing the suggested change.
@brouberol
Copy link
Contributor Author

@k4black thanks for the feedback! We should be good. I've rebased my branch on your main, and the code is now fully backwards compatible.

@k4black k4black changed the title Resolve deprecation warning by using explicit UTC timezone instead of datetime.utcnow fix: Resolve deprecation warning by using explicit UTC timezone instead of datetime.utcnow Nov 2, 2023
@k4black
Copy link
Owner

k4black commented Nov 2, 2023

lgtm, thank you! <3
published as 0.2.0

@k4black k4black merged commit 60812d4 into k4black:main Nov 2, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants