Skip to content

[master] Datetime utcnow - #66902

Merged
dwoz merged 2 commits into
saltstack:masterfrom
marmarek:datetime-utcnow
Mar 18, 2026
Merged

dwoz merged 2 commits into
saltstack:masterfrom
marmarek:datetime-utcnow

Conversation

@marmarek

Copy link
Copy Markdown
Contributor

What does this PR do?

This removes some usage of deprecated datetime.datetime.utcnow() and replaces them with timezone-aware objects, while not changing the actual behavior.

What issues does this PR fix or reference?

Partial fix for #65604

This is complementary to #66042

Previous Behavior

Salt logs warnings like:

/usr/lib/python3.12/site-packages/salt/utils/jid.py:19: 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).

New Behavior

No warning.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

@marmarek
marmarek requested a review from a team as a code owner September 18, 2024 15:10
@salt-project-bot-prod-environment salt-project-bot-prod-environment Bot changed the title Datetime utcnow [master] Datetime utcnow Sep 18, 2024

@twangboy twangboy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like you have some pre-commit failures

@marmarek

Copy link
Copy Markdown
Contributor Author

Looks like you have some pre-commit failures

Fixed

@twangboy

Copy link
Copy Markdown
Contributor

Looks like the test failures are related to your changes in utils/pkg/rpm.py

dmurphy18
dmurphy18 previously approved these changes Sep 18, 2024
@marmarek

Copy link
Copy Markdown
Contributor Author

Looks like the test failures are related to your changes in utils/pkg/rpm.py

What test failures? For the current version I don't see any (there are either green, or pending)

@twangboy

Copy link
Copy Markdown
Contributor

@marmarek

Copy link
Copy Markdown
Contributor Author

Ah, I see, datetime.UTC alias is available only since Python 3.11. Fixed.

@marmarek

marmarek commented Apr 8, 2025

Copy link
Copy Markdown
Contributor Author

Now a bunch of errors like this:

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help
      
      error: invalid command 'bdist_wheel'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for yamlordereddictloader

...

@twangboy

twangboy commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

Maybe we'll need to wait until we get the branch builds green again, and then rebase this one.

@marmarek

marmarek commented Apr 9, 2025

Copy link
Copy Markdown
Contributor Author

This looks to be related to pypa/wheel#662, and I see there is a workaround committed to 3006.x already: ec3178f. When merge to master is done usually?

@twangboy

Copy link
Copy Markdown
Contributor

First we'll get things merged to 3007.x... then merge forward from there to master

@twangboy twangboy added the test:full Run the full test suite label Jul 1, 2025
@twangboy

Copy link
Copy Markdown
Contributor

Please rebase and resolve conflicts

datetime.datetime.utcnow() is deprecated in Python 3.12, and it's
recommended to switch to timezone-aware objects, so do this. It also
simplifies local time handling, as .astimezone() method can be used
instead of calculating timezone_delta manually.

Part of saltstack#65604

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants