Repository navigation
tech-debt: normalize inline datetime.now(utc).isoformat() onto utc_timestamp() (#12726) - #12834
Merged
Merged
Conversation
…mestamp() (#12726) 100 inline call sites across 44 files replaced with the canonical helper (autobot_shared/time_utils.py:49), which is literally the same expression — so this is a pure style/consistency change with no behaviour delta. Verified the formats match, including the '+00:00' suffix. The canonical definition itself is deliberately untouched: rewriting time_utils.utc_timestamp() to call itself would be infinite recursion. Three things this sweep turned up that a blind find/replace would have shipped: 1. SyntaxError. My import-insertion regex matched the OPENING line of a multi-line `from autobot_shared.tracing import (` block and inserted inside the parentheses, breaking initialization/lifespan.py (E999). Caught by flake8, not by the replace step. Every changed file is now AST-parsed. 2. Newly-unused imports. Removing the last inline use left `from datetime import datetime, timezone` orphaned in 24 files — including two FUNCTION-LOCAL (indented) imports that a top-level-only regex missed. Cleaned iteratively, driven by flake8 F401 output rather than guesswork, and only where genuinely unused (files still using datetime elsewhere keep it). 3. A comment-only rewrite. In drift_checker_test.py the sole occurrence was inside a comment, so the sweep edited prose and added an import nothing used. That file is reverted — the sweep should change code, not commentary. Verification: flake8 clean (0 findings) across all 44 changed files; isort and black clean; every file AST-parses. knowledge/backends + desktop_control_lock: 38 failed / 63 passed — byte-identical to an unmodified tree (pre-existing chromadb-unavailable failures). Closes #12726
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thinking Path
Picked as an unblocked, purely mechanical issue.
utc_timestamp()(autobot_shared/time_utils.py:49) is literallydatetime.now(timezone.utc).isoformat(), so this is a consistency change with no behaviour delta — confirmed by comparing output formats including the+00:00suffix.The canonical definition itself is deliberately untouched: rewriting
time_utils.utc_timestamp()to call itself would be infinite recursion.What Changed
100 inline call sites across 44 files replaced with the canonical helper, imports added where missing.
Three things a blind find/replace would have shipped
Worth listing, because each was caught by verification rather than by the edit step:
1. A SyntaxError. My import-insertion regex matched the opening line of a multi-line
from autobot_shared.tracing import (block and inserted inside the parentheses, breakinginitialization/lifespan.py(E999). flake8 caught it; the replace step had no idea. Every changed file is now AST-parsed.2. Newly-unused imports. Removing the last inline use orphaned
from datetime import datetime, timezonein 24 files — including two function-local (indented) imports that a top-level-only regex missed. Cleaned iteratively, driven by flake8 F401 output rather than guesswork, and only where genuinely unused: files still usingdatetimeelsewhere keep it.3. A comment-only rewrite. In
drift_checker_test.pythe sole occurrence was inside a comment, so the sweep edited prose and added an import nothing used. That file is reverted — a sweep should change code, not commentary.Verification
Those 38 are pre-existing chromadb-unavailable failures, present unmodified on
Dev_new_gui.Model Used
Claude Opus 5 (1M context)
Closes #12726