• 
      

    Update all datetime/timezone usage to avoid deprecated functionality.

    Review Request #13429 — Created Nov. 22, 2023 and submitted

    Information

    Djblets
    release-5.x

    Reviewers

    Django has deprecated django.utils.timezone.utc in favor of
    datetime.timezone.utc. The rest of the django.utils.timezone methods
    are still supported. Furthermore, datetime.timezone.utc cannot be
    directly imported, and must be accessed through datetime.timezone.

    This leaves two possible importable targets named datetime (both
    datetime and datetime.datetime) and named timezone
    (datetime.timezone and django.utils.timezone), all of which are
    relevant.

    In an effort to keep things sane and consistent, the codebase now
    imports the top-level datetime (accessing everything as a direct
    property access of that) and django.utils.timezone as timezone in
    all affected modules. We may opt to go this route with all new Django
    code going forward.

    With this change, all datetime-related warnings in unit tests have been
    removed.

    All unit tests pass.

    Summary ID
    Update all datetime/timezone usage to avoid deprecated functionality.
    Django has deprecated `django.utils.timezone.utc` in favor of `datetime.timezone.utc`. The rest of the `django.utils.timezone` methods are still supported. Furthermore, `datetime.timezone.utc` cannot be directly imported, and must be accessed through `datetime.timezone`. This leaves two possible importable targets named `datetime` (both `datetime` and `datetime.datetime`) and named `timezone` (`datetime.timezone` and `django.utils.timezone`), all of which are relevant. In an effort to keep things sane and consistent, the codebase now imports the top-level `datetime` (accessing everything as a direct property access of that) and `django.utils.timezone` as `timezone` in all affected modules. We may opt to go this route with all new Django code going forward. With this change, all datetime-related warnings in unit tests have been removed.
    e1093159b55a9e930fa00e5652f560fabc034dbd
    Description From Last Updated

    Looks like you missed this one, this should be changed to just import datetime and the rest of the code …

    maubinmaubin
    maubin
    1. 
        
    2. djblets/util/tests/test_dates.py (Diff revision 1)
       
       
      Show all issues

      Looks like you missed this one, this should be changed to just import datetime and the rest of the code updated appropriately.

    3. 
        
    chipx86
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-5.x (8e7e27d)