alecthomas / importmagic

A Python library for finding unresolved symbols in Python code, and the corresponding imports
BSD 2-Clause "Simplified" License
120 stars 20 forks source link

Whitespace missing while updating imports #28

Closed ChillarAnand closed 8 years ago

ChillarAnand commented 8 years ago

import pandas as pd is getting converted to import pandasas pd

Steps to reproduce:

In [10]: python_source
Out[10]: 'import pandas as pd\n\n\nfrom django.core.management.base import BaseCommand\n\n\n\npd.read_csv()\nx = BaseCommad\n'

In [11]: unresolved, unreferenced = scope.find_unresolved_and_unreferenced_symbols()

In [12]: importmagic.update_imports(python_source, index, unresolved, unreferenced)
Out[12]: 'import pandasas pd\n\n\npd.read_csv()\nx = BaseCommad\n'
alecthomas commented 8 years ago

I believe this is fixed in master. I will do a new release shortly.

alecthomas commented 8 years ago

I just released 0.1.5 which has a lot of fixes. I'm going to close this under the assumption that the issues are fixed. Reopen it if not.

ChillarAnand commented 8 years ago

Fixed in 0.1.5. Thank you :-)