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

django.utils.timezone.utc import not removed when unused #531

Open
shaib opened this issue Feb 9, 2025 · 0 comments
Open

django.utils.timezone.utc import not removed when unused #531

shaib opened this issue Feb 9, 2025 · 0 comments

Comments

@shaib
Copy link

shaib commented Feb 9, 2025

Python Version

3.12.8

Django Version

stable/5.2.x

Package Version

1.22.2

Description

Just found out ("the hard way", which wasn't that hard) that the utils_timezone fixer did not fix a migration when it imported utc from django.utils.timezone but never used it. The change is still necessary, because the failing import breaks the migration.

I'd like to add a test along the lines of

def test_unused_import():
    check_transformed(
        """\
        import datetime
        from django.utils.timezone import utc
        do_a_thing()
        """,
        """\
        import datetime
        do_a_thing()
        """,
    )

(I haven't yet verified that this test fails, but I have verified it isn't there currently...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant