browniebroke / django-codemod

A tool to automatically fix Django deprecations.

Home Page:https://django-codemod.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extra imports added with libCST 0.3.14 and above

browniebroke opened this issue · comments

Describe the bug
When installing this library fresh with the latest version of libCST (0.3.16 at time of writing), some extra imports are being added to modules which should not be changed.

If I downgrade to libCST 0.3.13, the codemodders work as expected, but from libCST 0.3.14 I can see this odd behaviour.

To Reproduce
On the readthedocs.org codebase:

Observe that some empty __init__.py files have some imports being added e.g.: from django.utils.translation import gettext as _ .

Additional context

Here is the diff between the 2 releases: Instagram/LibCST@v0.3.13...v0.3.14

One thing that stands out: Instagram/LibCST#402

Workaround
We should pin libCST to 0.3.13.

I've added a more minimal test case: https://github.com/browniebroke/django-codemod/blob/main/tests/test_e2e.sh

Works with libCST==0.3.13, breaks with libCST>=0.3.14.

Now fixed with LibCST 0.3.17