Skip to content

Fix/deprecated datetime utcnow#68883

Open
d3flex wants to merge 3 commits intosaltstack:masterfrom
d3flex:fix/deprecated_datetime_utcnow
Open

Fix/deprecated datetime utcnow#68883
d3flex wants to merge 3 commits intosaltstack:masterfrom
d3flex:fix/deprecated_datetime_utcnow

Conversation

@d3flex
Copy link
Copy Markdown

@d3flex d3flex commented Apr 2, 2026

What does this PR do?

  • replaces deprecated datetime.utcnow()
  • fix pylint problems when running pre-commit

What issues does this PR fix or reference?

Fixes #65604
Not sure if there is issue for the pylint

Previous Behavior

[DEBUG   ] The functions from module 'zfs' are being loaded by dir() on the loaded module
/usr/lib/python3.13/site-packages/salt/grains/core.py:2881: 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 utcnow warnings

Merge requirements satisfied?

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

Commits signed with GPG?

Yes

d3flex added 3 commits April 2, 2026 08:24
…(UTC)

datetime.utcnow() is deprecated since Python 3.12 and returns a naive
datetime object. Replaced with datetime.now(timezone.utc) across all
affected modules and utilities to produce timezone-aware datetimes.
drop `pip<21.2 and setuptools<58.0 from `.pre-commit-config.yaml` as those
versions depend on distutils which was removed in Python 3.13 and seems had
dropped in other place already.

Nevertheless the pylint keeps complaining about W8410
(3rd-party-module-not-gated) and it was explicitely excluded to avoid the
pulint from failing.
Update for issue 65604

Signed-off-by: Ioannis Bonatakis <ybonatakis@suse.com>
@d3flex d3flex requested a review from a team as a code owner April 2, 2026 07:14
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.

[TECH DEBT] datetime.datetime.utcnow() is deprecated in Python 3.12

2 participants