Skip to content

Use timezone-aware objects to represent datetimes in UTC.#341

Closed
fujitatomoya wants to merge 1 commit intorollingfrom
fujitatomoya/use-timezone-aware-objects
Closed

Use timezone-aware objects to represent datetimes in UTC.#341
fujitatomoya wants to merge 1 commit intorollingfrom
fujitatomoya/use-timezone-aware-objects

Conversation

@fujitatomoya
Copy link
Contributor

address following deprecation warnings.

root@tomoyafujita:~/ros2_ws/colcon_ws# colcon test --event-handlers console_direct+ --packages-select sros2
...
=============================== warnings summary ===============================
test/test_flake8.py: 16 warnings
  Warning: This process (pid=242453) is multi-threaded, use of fork() may lead to deadlocks in the child.

test/sros2/commands/security/verbs/test_create_enclave.py: 10 warnings
test/sros2/commands/security/verbs/test_create_keystore.py: 4 warnings
test/sros2/commands/security/verbs/test_create_permission.py: 5 warnings
test/sros2/commands/security/verbs/test_generate_artifacts.py: 24 warnings
test/sros2/commands/security/verbs/test_list_enclaves.py: 10 warnings
test/sros2/keystore/test_enclave.py: 2 warnings
  Warning: 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).

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
------ generated xml file: /root/ros2_ws/colcon_ws/build/sros2/pytest.xml ------
================= 35 passed, 71 warnings in 122.06s (0:02:02) ==================
--- stderr: sros2

=============================== warnings summary ===============================
test/test_flake8.py: 16 warnings
  Warning: This process (pid=242453) is multi-threaded, use of fork() may lead to deadlocks in the child.

test/sros2/commands/security/verbs/test_create_enclave.py: 10 warnings
test/sros2/commands/security/verbs/test_create_keystore.py: 4 warnings
test/sros2/commands/security/verbs/test_create_permission.py: 5 warnings
test/sros2/commands/security/verbs/test_generate_artifacts.py: 24 warnings
test/sros2/commands/security/verbs/test_list_enclaves.py: 10 warnings
test/sros2/keystore/test_enclave.py: 2 warnings
  Warning: 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).

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
---
Finished <<< sros2 [2min 4s]

Summary: 1 package finished [2min 6s]
  1 package had stderr output: sros2

Note

even with this PR, there are still same warnings come up. i think these are from dependent modules, because there is nowhere else sros2 uses deprecated API.

Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
@fujitatomoya fujitatomoya requested a review from ahcorde May 6, 2025 15:17
@fujitatomoya fujitatomoya self-assigned this May 6, 2025
@fujitatomoya
Copy link
Contributor Author

Pulls: #341
Gist: https://gist.githubusercontent.com/fujitatomoya/7077f1acb89710aca47c9777b162d9ca/raw/7c80a3d4cf77201536a58977fd2635a5ce8d01c9/ros2.repos
BUILD args: --packages-above-and-dependencies sros2
TEST args: --packages-above sros2
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/15919

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.94%. Comparing base (59fe530) to head (9ef5948).
Report is 2 commits behind head on rolling.

Additional details and impacted files
@@           Coverage Diff            @@
##           rolling     #341   +/-   ##
========================================
  Coverage    88.94%   88.94%           
========================================
  Files           24       24           
  Lines          615      615           
  Branches        64       64           
========================================
  Hits           547      547           
  Misses          50       50           
  Partials        18       18           
Flag Coverage Δ
unittests 88.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mikaelarguedas
Copy link
Member

thanks @fujitatomoya , this looks similar in purpose as #300 that removes every use of utcnow in sros2.
Any chance to get #300 tested for integration into kilted ? 🙏

@fujitatomoya
Copy link
Contributor Author

@mikaelarguedas thanks for the info! let's work on #300

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.

3 participants