Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marmarek opened this issue Nov 23, 2023 · 2 comments · May be fixed by #66042
Open

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

marmarek opened this issue Nov 23, 2023 · 2 comments · May be fixed by #66042
Labels
good first issue good for someone new to salt tech-debt
Milestone

Comments

@marmarek
Copy link
Contributor

Description of the tech debt to be addressed, include links and screenshots

Using salt-ssh results in the following warning:

/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).

Versions Report

(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)

This is salt-ssh called from/to Fedora 39

Salt Version:
          Salt: 3006.4
 
Python Version:
        Python: 3.12.0 (main, Oct  2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)]
 
Dependency Versions:
          cffi: 1.15.1
      cherrypy: Not Installed
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.5
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.20
      pycrypto: Not Installed
  pycryptodome: 3.19.0
        pygit2: Not Installed
  python-gnupg: Not Installed
        PyYAML: 6.0.1
         PyZMQ: 25.1.0
        relenv: Not Installed
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 6.3.3
           ZMQ: 4.3.4
 
System Versions:
          dist: fedora 39 
        locale: utf-8
       machine: x86_64
       release: 6.5.10-1.qubes.fc37.x86_64
        system: Linux
       version: Fedora Linux 39 
@s0undt3ch s0undt3ch added this to the Argon v3008 milestone Nov 23, 2023
@s0undt3ch s0undt3ch added the good first issue good for someone new to salt label Nov 23, 2023
@s0undt3ch
Copy link
Collaborator

This should be fairly trivial to fix

from datetime import datetime, timezone

Then, every occurrence of:

datetime.utcnow()

Should get replaced by:

datetime.now(tz=timezone.utc)

We'd love to get a PR addressing this 😁

abismor added a commit to abismor/salt that referenced this issue Nov 24, 2023
…() with datetime.now(tz=timezone.utc)

Update imports to accomodate this change

Resolves issue saltstack#65604
abismor added a commit to abismor/salt that referenced this issue Nov 24, 2023
…() with datetime.now(tz=timezone.utc)

Update imports to accomodate this change

Resolves issue saltstack#65604
@gabrielrosendo
Copy link

Is this open?

vorenhoutgithub added a commit to vorenhoutgithub/Plugwise-2-py that referenced this issue Apr 28, 2024
marmarek added a commit to marmarek/salt that referenced this issue Sep 18, 2024
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
marmarek added a commit to marmarek/salt that referenced this issue Sep 18, 2024
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
marmarek added a commit to marmarek/salt that referenced this issue Sep 18, 2024
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
marmarek added a commit to marmarek/salt that referenced this issue Sep 18, 2024
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
marmarek added a commit to marmarek/salt that referenced this issue Sep 18, 2024
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
marmarek added a commit to marmarek/salt that referenced this issue Sep 19, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue good for someone new to salt tech-debt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants