Skip to content

utils_timezone fixer doesn't seem to consider ast.ImportFrom nodes. #568

@rsiemens

Description

@rsiemens

Python Version

3.10.11

Django Version

4.2.21

Package Version

1.25.0

Description

Hi Adam 👋

When trying to apply the utils_timezone fixer to some files I noticed it failed to apply some fixes. Below is a simple set of code you can use to reproduce:

from django.utils import timezone
from datetime import datetime

print(datetime.now(tz=timezone.utc))

Running django-upgrade --target-version=5.2 --only=utils_timezone simple_reproduction.py will not apply any transforms. At a quick glance it seems like when building the ImportDetails the code isn't looking for ast.ImportFrom nodes when identifying the datetime_module.

Thanks for your work on this package!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions