Skip to content

refactor(health): replace deprecated datetime.utcnow() with timezone-aware datetime#1056

Open
MrButtCode wants to merge 3 commits intoCCExtractor:masterfrom
MrButtCode:fix/datetime-deprecation
Open

refactor(health): replace deprecated datetime.utcnow() with timezone-aware datetime#1056
MrButtCode wants to merge 3 commits intoCCExtractor:masterfrom
MrButtCode:fix/datetime-deprecation

Conversation

@MrButtCode
Copy link

@MrButtCode MrButtCode commented Mar 8, 2026

Resolves multiple DeprecationWarnings in mod_health/controllers.py caused by the use of datetime.utcnow().

Python 3.12 formally deprecated datetime.utcnow() in favor of timezone-aware objects. To harden the health module for newer Python runtimes while preserving the exact JSON API contract for existing consumers, I migrated the calls to datetime.now(timezone.utc).

By using a proper timezone aware object the native isoformat() method automatically handles the UTC offset perfectly. This ensures flawless backward compatability with the current frontend consumers while satisfying the new Python 3.12 requirements without needing any manual string concatenation.

@canihavesomecoffee canihavesomecoffee force-pushed the fix/datetime-deprecation branch from a02956e to f4b62ba Compare March 15, 2026 09:21
@sonarqubecloud
Copy link

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