landscapeio / requirements-detector

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unicode hack destroys indentation

Kriechi opened this issue · comments

I was trying to use this tool on a setup.py file with valid syntax.

# -*- coding: UTF-8 -*-
from distutils.core import setup

if foo:
    # just for a test with indentation
    bar()

setup(
    name=u'prospector-test-4-üéø',
    version='0.0.1',
    install_requires=[
        'Django==1.5.0',
        'django-gubbins==1.1.2'
    ]
)

Unfortunately this hack destroys the line indentation, and therefore produces invalid python code. This leads to an exception in AstroidBuilder (being catched here).
Since parsing setup.py yielded an error, it falls back to parse requirements.txt - which in my case is empty.

Proposed solution:
Don't remove leading whitespace during _load_file_contents. I would have tried working on a fix myself, but I didn't quite understand the unicode hack involved here - I didn't want to break anything else...
Or is it enough to simply remove the .strip() from here?

Finally fixed in version 0.5.1 now on PyPi :)