Skip to content

fix: datetime.datetime.utcnow() is deprecated#2173

Merged
degenaro merged 3 commits into
oscal-compass:developfrom
LAKSHJAIN14:fix/deprecationWarning-datetime
Mar 23, 2026
Merged

fix: datetime.datetime.utcnow() is deprecated#2173
degenaro merged 3 commits into
oscal-compass:developfrom
LAKSHJAIN14:fix/deprecationWarning-datetime

Conversation

@LAKSHJAIN14

@LAKSHJAIN14 LAKSHJAIN14 commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Types of changes

  • Hot fix (emergency fix and release)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation (change which affects the documentation site)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Release (develop -> main)

Summary

while running tests there are warnings related to Deprecation of datetime.datetime.utcnow()

trestle/tasks/csv_to_oscal_mc.py:66: 16 warnings
  /mnt/d/compliance-trestle/trestle/tasks/csv_to_oscal_mc.py:66: 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).
    timestamp = datetime.datetime.utcnow().replace(microsecond=0).replace(tzinfo=datetime.timezone.utc).isoformat()

tests/trestle/tasks/csv_to_oscal_mc_test.py: 24 warnings
  /mnt/d/compliance-trestle/trestle/tasks/csv_to_oscal_mc.py:127: 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).
    datetime.datetime.utcnow().replace(microsecond=0).replace(tzinfo=datetime.timezone.utc).isoformat()

These changes should fix the issue and running the tests after the changes had no more warnings related to this
@degenaro

Signed-off-by: LAKSHJAIN14 <jainlaksh07@gmail.com>
Signed-off-by: LAKSHJAIN14 <jainlaksh07@gmail.com>
@LAKSHJAIN14 LAKSHJAIN14 requested a review from a team as a code owner March 21, 2026 14:39
@degenaro

Copy link
Copy Markdown
Collaborator
image

@degenaro degenaro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@degenaro degenaro merged commit 87fe40b into oscal-compass:develop Mar 23, 2026
16 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