You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the codebase uses datetime.utcnow() or datetime.utcfromtimestamp(). These are deprecated and won't work with Python 3.12. They also handle naïve datetimes, which can lead to bugs. Could we switch to timezone-aware alternatives?
Hi there! 👋
I noticed that the codebase uses
datetime.utcnow()
ordatetime.utcfromtimestamp()
. These are deprecated and won't work with Python 3.12. They also handle naïve datetimes, which can lead to bugs. Could we switch to timezone-aware alternatives?CodeQL Alerts
Here are the specific instances CodeQL flagged:
whitebox/whitebox/crud/base.py
Line 37 in 9524d86
whitebox/whitebox/crud/base.py
Line 48 in 9524d86
whitebox/whitebox/crud/base.py
Line 69 in 9524d86
whitebox/whitebox/core/manager.py
Line 31 in 9524d86
whitebox/whitebox/cron_tasks/monitoring_alerts.py
Line 57 in 9524d86
whitebox/whitebox/cron_tasks/monitoring_alerts.py
Line 91 in 9524d86
whitebox/whitebox/cron_tasks/monitoring_metrics.py
Line 263 in 9524d86
whitebox/whitebox/schemas/task.py
Line 13 in 9524d86
Explanation
Issue:
datetime.utcnow()
anddatetime.utcfromtimestamp()
return naïve datetimes (without timezone info).Example Problem:
Recommended Solution:
Switch to time zone-aware methods:
Action Required:
datetime.utcnow()
withdatetime.now(tz=timezone.utc)
.datetime.utcfromtimestamp()
withdatetime.fromtimestamp(ts, tz=timezone.utc)
.References:
For more details, see:
Thank you so much for your time and effort in maintaining this project! 🌟
Best,
Shrey
The text was updated successfully, but these errors were encountered: