Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Do not use utc_now on module level
Looks like that this value is never used anywhere, and it should not be, because it is created once on a module import time.

I found this while working on python/typeshed#13514
  • Loading branch information
sobolevn authored Feb 21, 2025
commit 72e00df86254507a92d7e0d1a165109e6a4d48c6
9 changes: 3 additions & 6 deletions jose/jwt.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import json
from calendar import timegm
from datetime import datetime, timedelta

try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping

try:
from datetime import UTC, datetime, timedelta

utc_now = datetime.now(UTC) # Preferred in Python 3.13+
from datetime import UTC # Preferred in Python 3.13+
except ImportError:
from datetime import datetime, timedelta, timezone

utc_now = datetime.now(timezone.utc) # Preferred in Python 3.12 and below
UTC = timezone.utc
UTC = timezone.utc # Preferred in Python 3.12 and below

from jose import jws

Expand Down